# Elasticsearch range filter not returning expected data

**URL:** <https://discuss.elastic.co/t/elasticsearch-range-filter-not-returning-expected-data/200190>\
**Category:** Elasticsearch\
**Created:** [September 19, 2019, 11:09am UTC](https://discuss.elastic.co/t/elasticsearch-range-filter-not-returning-expected-data/200190 "2019-09-19T11:09:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maneesh](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@Maneesh](https://discuss.elastic.co/u/Maneesh)\
**Post date:** [September 19, 2019, 11:09am UTC](https://discuss.elastic.co/t/elasticsearch-range-filter-not-returning-expected-data/200190/1 "2019-09-19T11:09:00Z")

</div>

I have a range data as shown below for each of the products:  
"regionRanges": [  
{"lowerLimit": "1000", "upperLimit": "1019"},  
{"lowerLimit": "1000","upperLimit": "1099"},  
{"lowerLimit": "3000","upperLimit": "3099"}  
]  
and user will be in a specific region (e.g. 1090) so how can i get all the product from a particular region.  
I had tried different query but those are not working as expected.

{  
"query": {  
"bool": {  
"must": [  
{  
"range": {  
"custom\_attributes.supplier.regionRanges.lowerLimit": {"lt": "1090"}  
}  
},  
{  
"range": {  
"custom\_attributes.supplier.regionRanges.upperLimit": {"gt": "1090"}  
}  
}  
],  
"must\_not": ,  
"should": [{"match\_all": {}}]  
}  
}  
}

Could you please help me out in figuring out where the query is getting wrong?  
I would like to get all the product which has the user region in their ranges.

Unlike the Price of the product where we give range and return all the products in that range, It's quite opposite like you have the region and get all those products for which this region is available in the product ranges.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 19, 2019, 1:01pm UTC](https://discuss.elastic.co/t/elasticsearch-range-filter-not-returning-expected-data/200190/2 "2019-09-19T13:01:55Z")

</div>

See [Elastic search range query not working](https://discuss.elastic.co/t/elastic-search-range-query-not-working/199831)

on top of that, you should look at the [nested datatype](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/nested.html) in order to get the correct results back.

---

<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 17, 2019, 1:01pm UTC](https://discuss.elastic.co/t/elasticsearch-range-filter-not-returning-expected-data/200190/3 "2019-10-17T13:01:57Z")

</div>

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