# Range Filter strange behavior for numeric datat ype like integer, long, double

**URL:** <https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470>\
**Category:** Elasticsearch\
**Created:** [April 6, 2013, 5:30am UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470 "2013-04-06T05:30:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vivek\_Muthal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_muthal/32/2407_2.png) [@Vivek\_Muthal](https://discuss.elastic.co/u/Vivek_Muthal)\
**Post date:** [April 6, 2013, 5:30am UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470/1 "2013-04-06T05:30:52Z")

</div>

I have a field with integer data type, i tried with long and double also.  
This field has values from 0 - 200.

I am using a simple filter which i had tried with from-to, gt-lt, gte-lte.  
The filter gives proper result but the strange behavior comes when i select  
0-100.  
When I select 0-99 it gives proper result suppose lets assume it return 15  
result.  
So when I select 0-100 it must show at least 15 or more but it wont it  
returns less than 15 result this is very strange behavior.  
Same for 0- more than 100 it means anything which is more than 100 it  
doesn't return proper result.

Please help, why this is happening? Is there any bug?  
(Note: I am talking about Range Filter, Not Range Query. Please Help.)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [April 6, 2013, 3:15pm UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470/2 "2013-04-06T15:15:02Z")

</div>

Hello,

This is rather strange - I certainly didn't experience it.

Can you please provide a curl  
recreation[http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)of the issue? That  
should help identify whether it's a problem with your  
approach or the software. Or maybe both 🙂

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

On Sat, Apr 6, 2013 at 8:30 AM, Vivek Muthal [vmuthal.18@gmail.com](mailto:vmuthal.18@gmail.com) wrote:

> I have a field with integer data type, i tried with long and double also.  
> This field has values from 0 - 200.
> 
> I am using a simple filter which i had tried with from-to, gt-lt, gte-lte.  
> The filter gives proper result but the strange behavior comes when i  
> select 0-100.  
> When I select 0-99 it gives proper result suppose lets assume it return 15  
> result.  
> So when I select 0-100 it must show at least 15 or more but it wont it  
> returns less than 15 result this is very strange behavior.  
> Same for 0- more than 100 it means anything which is more than 100 it  
> doesn't return proper result.
> 
> Please help, why this is happening? Is there any bug?  
> (Note: I am talking about Range Filter, Not Range Query. Please Help.)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Vivek\_Muthal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_muthal/32/2407_2.png) [@Vivek\_Muthal](https://discuss.elastic.co/u/Vivek_Muthal)\
**Post date:** [April 9, 2013, 10:18am UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470/3 "2013-04-09T10:18:56Z")

</div>

Hello,  
The field is map to integer only.

This is the json which is in $q :  
{  
"from": 0,  
"size": "20",  
"filter": {  
"bool": {  
"must": {  
"range": {  
"resume.experience": {  
"gte": 0,  
"lte": 101  
}  
}  
}  
}  
}  
}

//curl -X post  
function query($type, $q){  
return $this-\>call($type . '/\_search?q?', array('method' =\>  
'POST','content' =\> $q));  
}  
function function call($path, $http = array()){  
{  
return json\_decode(file\_get\_contents($this-\>server . '/' . $this-\>index .  
'/' . $path, NULL, stream\_context\_create(array('http' =\> $http))));  
}

I tried with different tools also facing same issue not filtering properly  
after 100.

On Saturday, April 6, 2013 8:45:02 PM UTC+5:30, Radu Gheorghe wrote:

> Hello,
> 
> This is rather strange - I certainly didn't experience it.
> 
> Can you please provide a curl recreation[http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)of the issue? That should help identify whether it's a problem with your  
> approach or the software. Or maybe both 🙂
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> On Sat, Apr 6, 2013 at 8:30 AM, Vivek Muthal \<[vmuth...@gmail.com](mailto:vmuth...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > I have a field with integer data type, i tried with long and double also.  
> > This field has values from 0 - 200.
> > 
> > I am using a simple filter which i had tried with from-to, gt-lt, gte-lte.  
> > The filter gives proper result but the strange behavior comes when i  
> > select 0-100.  
> > When I select 0-99 it gives proper result suppose lets assume it return  
> > 15 result.  
> > So when I select 0-100 it must show at least 15 or more but it wont it  
> > returns less than 15 result this is very strange behavior.  
> > Same for 0- more than 100 it means anything which is more than 100 it  
> > doesn't return proper result.
> > 
> > Please help, why this is happening? Is there any bug?  
> > (Note: I am talking about Range Filter, Not Range Query. Please Help.)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Vivek\_Muthal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_muthal/32/2407_2.png) [@Vivek\_Muthal](https://discuss.elastic.co/u/Vivek_Muthal)\
**Post date:** [April 9, 2013, 10:39am UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470/4 "2013-04-09T10:39:41Z")

</div>

Hello,  
The field is map to integer only.

This is the json which is in $q :  
{  
"from": 0,  
"size": "20",  
"filter": {  
"bool": {  
"must": {  
"range": {  
"experience": {  
"gte": 0,  
"lte": 101  
}  
}  
}  
}  
}  
}

//curl -X post  
function query($type, $q){  
return $this-\>call($type . '/\_search?q?', array('method' =\>  
'POST','content' =\> $q));  
}  
function function call($path, $http = array()){  
{  
return json\_decode(file\_get\_contents(  
$this-\>server . '/' . $this-\>index . '/' . $path, NULL,  
stream\_context\_create(array('http' =\> $http))));  
}

I tried with different tools also facing same issue not filtering properly  
after 100.

On Saturday, April 6, 2013 8:45:02 PM UTC+5:30, Radu Gheorghe wrote:

> Hello,
> 
> This is rather strange - I certainly didn't experience it.
> 
> Can you please provide a curl recreation[http://www.elasticsearch.org/help/](http://www.elasticsearch.org/help/)of the issue? That should help identify whether it's a problem with your  
> approach or the software. Or maybe both 🙂
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> On Sat, Apr 6, 2013 at 8:30 AM, Vivek Muthal \<[vmuth...@gmail.com](mailto:vmuth...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > I have a field with integer data type, i tried with long and double also.  
> > This field has values from 0 - 200.
> > 
> > I am using a simple filter which i had tried with from-to, gt-lt, gte-lte.  
> > The filter gives proper result but the strange behavior comes when i  
> > select 0-100.  
> > When I select 0-99 it gives proper result suppose lets assume it return  
> > 15 result.  
> > So when I select 0-100 it must show at least 15 or more but it wont it  
> > returns less than 15 result this is very strange behavior.  
> > Same for 0- more than 100 it means anything which is more than 100 it  
> > doesn't return proper result.
> > 
> > Please help, why this is happening? Is there any bug?  
> > (Note: I am talking about Range Filter, Not Range Query. Please Help.)

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [April 9, 2013, 12:09pm UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470/5 "2013-04-09T12:09:25Z")

</div>

On Tue, 2013-04-09 at 03:39 -0700, Vivek Muthal wrote:

> Hello,  
> The field is map to integer only.

Are you sure?

If the field is actually type 'string', then it will sort terms  
alphabetically, not numerically.

This is why Radu asked for a complete recreation, not just the query

clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Vivek\_Muthal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vivek_muthal/32/2407_2.png) [@Vivek\_Muthal](https://discuss.elastic.co/u/Vivek_Muthal)\
**Post date:** [April 9, 2013, 1:18pm UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470/6 "2013-04-09T13:18:43Z")

</div>

@Radu and @Clinton thanks for support 🙂

You are right, I used a tool to see actual data types, it mapped all  
field's to string except date.  
I am using a library where i set the properties, Dont know it's problem of  
library or anything else that it maps all fields to string. But at least it  
helped me to figure out the problem, the problem is data type. I have to  
find a way to map fields properly.

"If the field is actually type 'string', then it will sort terms  
alphabetically, not numerically. " This sentence helped me a lot. Thanks  
for support 🙂

On Tuesday, April 9, 2013 5:39:25 PM UTC+5:30, Clinton Gormley wrote:

> On Tue, 2013-04-09 at 03:39 -0700, Vivek Muthal wrote:
> 
> > Hello,  
> > The field is map to integer only.
> 
> Are you sure?
> 
> If the field is actually type 'string', then it will sort terms  
> alphabetically, not numerically.
> 
> This is why Radu asked for a complete recreation, not just the query
> 
> clint

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:42am UTC](https://discuss.elastic.co/t/range-filter-strange-behavior-for-numeric-datat-ype-like-integer-long-double/11470/7 "2017-07-06T02:42:02Z")

</div>


