ES query to Perform Search based on the given keywords and get results only within the Specific DateRange

Hello All,

I am trying to create a query to perform search based on provided keywords
and within a specific date range

Query 1 : To Test DateRange -
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
'{"query":{"range":{"Date":{"from":"2012-10-03T13:52:45","to":"2012-10-03T13:55:00"}}}}'
Works perfectly fine and the output results are 6 records


Query 2 : To Test Keyword search -
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
'{"query":{"match":{"_all":{"query":"London USA","operator":"or"}}}}'
Works perfectly fine and the output results are 3 records (Note: The Data
Range for these 3 records are within the same range as in the 1st query - I
have manually checked _source.Date field)

Now to search for these keywords and within the same date range using a
single Query I should be able to see only 3 records, so to achive this I
have tried below queries and failed :

Query 3: Just combined Keyword search query 2 and Date Range search query 1
into single query -
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
'{"query":{"match":{"_all":{"query":"London
USA","operator":"or"}}},"range":{"Date":{"from":"2012-10-03T13:52:45","to":"2012-10-03T13:55:00"}}}'

Result: "error" : "SearchPhaseExecutionException[Failed to execute phase
[query], nested: SearchParseException[[Index][4]: query[Date:[1349272365000
TO 1349272500999]],from[-1],size[-1]: Parse Failure [No parser for element
[match]]]; }]", "status" : 500


Query 4: Tried to join the queries using "Bool"
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
'{"query":{"bool":{"must":{"match":{"_all":{"query":"London
USA","operator":"or"}}}},"must":{"query":{"range":{"Date":{"from":"2012-10-03T13:52:45","to":"2012-10-03T13:55:00"}}}}}}'

Result: No error, but brings back 6 records that are same as the results
from the date range query 1.
So here I think "Bool" will combine the queries but brings back the
combination of results from both the queries.


Query 5: Tried using Filter and Match
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
'{"query":{"range":{"Date":{"from":"2012-10-03T13:52:45","to":"2012-10-03T13:55:00"}}},"filter":{"match":{"_all":{"query":"London
USA","operator":"or"}}}}'
Result: Error for below query: No filter registered for [match]]


Query 6: Tried using Filter and Term
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
'{"query":{"range":{"Date":{"from":"2012-10-03T13:52:45","to":"2012-10-03T13:55:00"}}},"filter":{"term":{"_all":"London
USA"}}}'
Output: Zero results


Query 7: Tried using Filter , Term and query
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
'{"query":{"range":{"Date":{"from":"2012-10-03T13:52:45","to":"2012-10-03T13:55:00"}}},"filter":{"term":{"_all":{"query":"London
USA"}}}}'
Output Error: [term] filter does not support [query]

Not sure How I can get the query working the way I wanted ?

Any help will be much appreciated.

Regards,
Shannu.

--