Querying Elasticsearch by combining a range and a term match json format
In your mapping you need to have method
as not_analyzed
(or analyzed with keyword
analyzer) and the query should use term
. In this way, the text you index in method is indexed as is as a single token and term
makes sure the text you search matches exactly the token indexed in method
:
"method": { "type": "string", "index": "not_analyzed" }
And the query you need to use:
{ "query": { "bool": { "must": [ { "term": { "method": "/customer/help" } }, { "range": { "startTime": { "from": "2015-10-20T13:00-04:00", "to": "2015-10-20T14:00-04:00" } } } ] } }}