Getting wrong result, while using range query as query string


(Hemant) #1

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


(ElasticSearch Users mailing list) #2

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


(system) #3