# Aggregation Range

**URL:** <https://discuss.elastic.co/t/aggregation-range/149645>\
**Category:** Elasticsearch\
**Created:** [September 24, 2018, 9:27am UTC](https://discuss.elastic.co/t/aggregation-range/149645 "2018-09-24T09:27:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikhil\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Nikhil\_Nambiar](https://discuss.elastic.co/u/Nikhil_Nambiar)\
**Post date:** [September 24, 2018, 9:27am UTC](https://discuss.elastic.co/t/aggregation-range/149645/1 "2018-09-24T09:27:14Z")

</div>

Hi,  
I have used range aggregation query to hit only those document whose amount is greater than or equal to 1000  
But it also gives me those doc with amount less than 1000.  
Is there any alternative query to get amount greater than 1000  
or Am I doing some mistake in my query.  
They query I fired is as follows,  
{  
"aggs" : {  
"rate\_ranges" : {  
"range" : {  
"field" : "amount",  
"ranges" : [  
{ "from" : 1000.0 }  
]  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [September 24, 2018, 11:14am UTC](https://discuss.elastic.co/t/aggregation-range/149645/2 "2018-09-24T11:14:03Z")

</div>

It seems like you have confused aggregations with queries.

Queries define the set of documents that should be matched while aggregations define how those matching documents should be grouped into buckets or otherwise summarised.

You need a `query` expression with a range

```
{
  "query": {
	"range": {
	  "amount": {
		"gte": 1000
	  }
	}
  }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 22, 2018, 11:14am UTC](https://discuss.elastic.co/t/aggregation-range/149645/3 "2018-10-22T11:14:15Z")

</div>

Closed on October 22, 2018, 11:14am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
