# Getting wrong result, while using range query as query string

**URL:** <https://discuss.elastic.co/t/getting-wrong-result-while-using-range-query-as-query-string/17509>\
**Category:** Elasticsearch\
**Created:** [May 14, 2014, 8:20am UTC](https://discuss.elastic.co/t/getting-wrong-result-while-using-range-query-as-query-string/17509 "2014-05-14T08:20:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hemant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hemant/32/1337_2.png) [@Hemant](https://discuss.elastic.co/u/Hemant)\
**Post date:** [May 14, 2014, 8:20am UTC](https://discuss.elastic.co/t/getting-wrong-result-while-using-range-query-as-query-string/17509/1 "2014-05-14T08:20:14Z")

</div>

I have Indexed some data with the following mapping

1. {
2. "inventory": {
3. "products": {
4. "properties": {
5. "exp\_date": {
6. "type": "date",
7. "format": "dateOptionalTime"
8. },
9. "man\_date": {
10. "type": "date",
11. "format": "dateOptionalTime"
12. },
13. "price": {
14. "type": "long"
15. },
16. "product\_description": {
17. "type": "string"
18. },
19. "product\_name": {
20. "type": "string"
21. },
22. "quan\_available": {
23. "type": "long"
24. }
25. }
26. }
27. }
28. }

Using [108 TO 110] as query string, results unwanted document to be  
selected in search result

[https://lh4.googleusercontent.com/-BI-JpAj0ymc/U3MmC9YNh2I/AAAAAAAAAYk/gEbNk9wRykc/s1600/ESrange.png](https://lh4.googleusercontent.com/-BI-JpAj0ymc/U3MmC9YNh2I/AAAAAAAAAYk/gEbNk9wRykc/s1600/ESrange.png)  
And when I add the field Name to the query string , the result is as  
expected.  
query string -\> price:[108 TO 110] returns correct result as follows

[https://lh6.googleusercontent.com/-nx9g-\_5RFvA/U3MmzhA4MqI/AAAAAAAAAYs/nxxyMhnvlME/s1600/ESrangewithfieldname.png](https://lh6.googleusercontent.com/-nx9g-_5RFvA/U3MmzhA4MqI/AAAAAAAAAYs/nxxyMhnvlME/s1600/ESrangewithfieldname.png)  
Any insight for this problem will be great.

Thanks In Advance.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/29129d48-7b4b-4fe1-afa2-f8746e0e6abb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/29129d48-7b4b-4fe1-afa2-f8746e0e6abb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![ElasticSearch\_Users\_](https://avatars.discourse-cdn.com/v4/letter/e/b4bc9f/32.png) [@ElasticSearch\_Users\_](https://discuss.elastic.co/u/ElasticSearch_Users_)\
**Post date:** [May 14, 2014, 1:53pm UTC](https://discuss.elastic.co/t/getting-wrong-result-while-using-range-query-as-query-string/17509/2 "2014-05-14T13:53:10Z")

</div>

When you do:

"query": "[108 TO 110]"

By default, it will look in the \_all field for terms to match the above  
criteria. The \_all field is a concatenation of all your field values in the  
JSON document (which will include fields other than price).

When you do:

"query": "price:[108 TO 110]"

You are telling ES to only look in the price field to match the range.

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0da5e183-33db-410f-bf8f-781893269dd9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0da5e183-33db-410f-bf8f-781893269dd9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:29am UTC](https://discuss.elastic.co/t/getting-wrong-result-while-using-range-query-as-query-string/17509/3 "2017-07-06T01:29:27Z")

</div>


