Problem while searching for date range or date

Hello,

I have indexed some data, with default 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. }

Now when I perform a search to match some date, I am not getting the
expected result.
Consider query like this
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "exp_date:[2013-03-1 TO 2013-03-5]"
}
}
}
},
"fields": [
"price",
"quan_available",
"product_name",
"product_description",
"exp_date",
"man_date"
],
"from": 0,
"size": 50,
"sort": {
"_score": {
"order": "asc"
}
},
"explain": true
}

Gives me expected result, that is all the documents which matches this date
range, but when I remove the field Name exp_date from the query string, I
am getting no result at all.
The following query results zero result.
{ "query": { "filtered": { "query": { "query_string": { "query":
"[2013-03-1 TO 2013-03-5]" } } } }, "fields": [ "price", "quan_available",
"product_name", "product_description", "exp_date", "man_date" ], "from": 0,
"size": 50, "sort": { "_score": { "order": "asc" } }, "explain": true }

Can anybody suggest solution to this problem? What am doing wrong?
Thansk 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/ef046043-c666-4d11-8bf9-b46d28b421eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Found the solution to same problem here -
https://groups.google.com/forum/#!searchin/elasticsearch/date/elasticsearch/eeTwWVf6Sfo/1jbHq0gca6QJ

Thanks.

On Friday, May 2, 2014 3:13:30 PM UTC+5:30, Hemant wrote:

Hello,

I have indexed some data, with default 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. }

Now when I perform a search to match some date, I am not getting the
expected result.
Consider query like this
{
"query": {
"filtered": {
"query": {
"query_string": {
"query": "exp_date:[2013-03-1 TO 2013-03-5]"
}
}
}
},
"fields": [
"price",
"quan_available",
"product_name",
"product_description",
"exp_date",
"man_date"
],
"from": 0,
"size": 50,
"sort": {
"_score": {
"order": "asc"
}
},
"explain": true
}

Gives me expected result, that is all the documents which matches this
date range, but when I remove the field Name exp_date from the query
string, I am getting no result at all.
The following query results zero result.
{ "query": { "filtered": { "query": { "query_string": { "query":
"[2013-03-1 TO 2013-03-5]" } } } }, "fields": [ "price", "quan_available",
"product_name", "product_description", "exp_date", "man_date" ], "from": 0,
"size": 50, "sort": { "_score": { "order": "asc" } }, "explain": true }

Can anybody suggest solution to this problem? What am doing wrong?
Thansk 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/5155a1ed-b2d2-4fa7-9f2e-c37dd3323d52%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.