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

(shannu) #1

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
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

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

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
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
Output: Zero results

Query 7: Tried using Filter , Term and query
curl -XGET 'http://localhost:9200/Index/Type/_search?pretty=true' -d
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.



(system) #2