# Range Query

**URL:** <https://discuss.elastic.co/t/range-query/3823>\
**Category:** Elasticsearch\
**Created:** [January 24, 2011, 2:51pm UTC](https://discuss.elastic.co/t/range-query/3823 "2011-01-24T14:51:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arulkumar](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Arulkumar](https://discuss.elastic.co/u/Arulkumar)\
**Post date:** [January 24, 2011, 2:51pm UTC](https://discuss.elastic.co/t/range-query/3823/1 "2011-01-24T14:51:29Z")

</div>

Hi All,

I have one question in range query....

1. How to search with only one range i.e, either from range or to  
range.....?

curl -XGET '[http://localhost:9200/dbtest/metadata/\_search](http://localhost:9200/dbtest/metadata/_search)' -d  
'{ "query":{ "range" : {"myfield" : {"from" : "1","to" : "\*",  
"include\_lower" : true, "include\_upper" : true}}}}'

I am getting error here is...

{"error":"SearchPhaseExecutionException[Failed to execute phase  
[query], total f  
ailure; shardFailures {[ILV-\_\_B3Tau7KR\_uqzlrSA][db2267][0]:  
RemoteTransportExcep  
tion[[Stegron][inet[/192.168.65.1:9302]][search/phase/query]]; nested:  
SearchPar  
seException[[db2267][0]: from[-1],size[-1]: Parse Failure [Failed to  
parse sourc  
e [{ "query" :{ "range" : {"m\_pagecount" : {"from" : "1","to  
" : "  
_", "include\_lower" : true, "include\_upper" : true}}}}]]]; nested:  
NumberForm  
atException[For input string: "_"]; }{[ILV-\_\_B3Tau7KR\_uqzlrSA]  
[db2267][1]: Rem  
oteTransportException[[Stegron][inet[/192.168.65.1:9302]][search/phase/  
query]];  
nested: SearchParseException[[db2267][1]: from[-1],size[-1]: Parse  
Failure [Fail  
ed to parse source [{ "query" :{ "range" : {"m\_pagecount" :  
{"from" : "  
1","to" : "_", "include\_lower" : true, "include\_upper" :  
true}}}}]]]; n  
ested: NumberFormatException[For input string: "_"]; }]"}

How can i search with only one range.......?

---

<div class="post-metadata">

**Author:** ![Ludovic\_Levesque](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ludovic_levesque/32/3031_2.png) [@Ludovic\_Levesque](https://discuss.elastic.co/u/Ludovic_Levesque)\
**Post date:** [January 24, 2011, 3:36pm UTC](https://discuss.elastic.co/t/range-query/3823/2 "2011-01-24T15:36:48Z")

</div>

Hi,

the documentation (  
[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/range\_query/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/range_query/)  
) tells this:  
"to": The upper bound. Defaults to unbounded.

So you can use same query without the "to" part (and remove the  
"include\_upper" too)

Ludo

On Mon, Jan 24, 2011 at 3:51 PM, Arulkumar [arulkumarcs@gmail.com](mailto:arulkumarcs@gmail.com) wrote:

> Hi All,
> 
> I have one question in range query....
> 
> 1. How to search with only one range i.e, either from range or to  
> range.....?
> 
> curl -XGET '[http://localhost:9200/dbtest/metadata/\_search](http://localhost:9200/dbtest/metadata/_search)' -d  
> '{ "query":{ "range" : {"myfield" : {"from" : "1","to" : "\*",  
> "include\_lower" : true, "include\_upper" : true}}}}'
> 
> I am getting error here is...
> 
> {"error":"SearchPhaseExecutionException[Failed to execute phase  
> [query], total f  
> ailure; shardFailures {[ILV-\_\_B3Tau7KR\_uqzlrSA][db2267][0]:  
> RemoteTransportExcep  
> tion[[Stegron][inet[/192.168.65.1:9302]][search/phase/query]]; nested:  
> SearchPar  
> seException[[db2267][0]: from[-1],size[-1]: Parse Failure [Failed to  
> parse sourc  
> e [{ "query" :{ "range" : {"m\_pagecount" : {"from" : "1","to  
> " : "  
> _", "include\_lower" : true, "include\_upper" : true}}}}]]]; nested:  
> NumberForm  
> atException[For input string: "_"]; }{[ILV-\_\_B3Tau7KR\_uqzlrSA]  
> [db2267][1]: Rem  
> oteTransportException[[Stegron][inet[/192.168.65.1:9302]][search/phase/  
> query]];  
> nested: SearchParseException[[db2267][1]: from[-1],size[-1]: Parse  
> Failure [Fail  
> ed to parse source [{ "query" :{ "range" : {"m\_pagecount" :  
> {"from" : "  
> 1","to" : "_", "include\_lower" : true, "include\_upper" :  
> true}}}}]]]; n  
> ested: NumberFormatException[For input string: "_"]; }]"}
> 
> How can i search with only one range.......?

---

<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, 4:13am UTC](https://discuss.elastic.co/t/range-query/3823/3 "2017-07-06T04:13:19Z")

</div>


