Elastic Search query

how to create one query with match sort by newer report date and martch_phrase sort by newer report and combine both result

Hi @ashish.akm,

Welcome to the community! I assume you're querying against a single index? Have you taken a look at bool query including your match and match_phrase terms?

Hi @carly.richmond
I am using below query but sort give me entire result with reportedate descending order, Where as I want sort by reportdate descending on "match_pharse" result set then "match" sort by reportedate descending.
GET /_search
{"reporteddate" : {"order": "desc", }}, "_score" }
"query": {
"bool": {
"should": [
"match_phrase": { "file.content": "query": "elections time" ,"boost": 10}
"match": { "file.content": "query": "elections time" }

Thanks for confirming @ashish.akm. I'm not aware of an ability to specify different sort criteria for each phrase in the query DSL. But you could have a look at writing a custom sort script in painless.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.