You can use the range filter for this, using the same date in gte / lte and a format , where you specify only part of the date (i.e. do not consider the time part)
{ "constant_score": { "filter": { "range" : { "IH_PT_DSC" : { "gte": "2015-04-02", "lte": "2015-04-02", "format": "yyyy-MM-dd" } } } } }
If you need to specify multiple dates, you can also do this easily.
{ "constant_score": { "filter": { "range" : { "IH_PT_DSC" : { "gte": "2015-04-01", "lte": "2015-04-03", "format": "yyyy-MM-dd" } } } } }
Finally, if you need to query for intermediate date ranges, just use the bool/should filter:
{ "constant_score": { "filter": { "bool": { "should": [ { "range": { <--- interval 1 "IH_PT_DSC": { "gte": "2015-04-01", "lte": "2015-04-03", "format": "yyyy-MM-dd" } } }, { "range": { <--- interval 2 "IH_PT_DSC": { "gte": "2015-04-05", "lte": "2015-04-08", "format": "yyyy-MM-dd" } } }, { "range": { <--- interval 3 "IH_PT_DSC": { "gte": "2015-04-10", "lte": "2015-04-12", "format": "yyyy-MM-dd" } } } ] } } } }
source share