I want to build an ElasticSearch query where I query multiple fields, but one of the words in the query MUST match one of the fields.
For instance, suppose I query for "holiday party food", I want it to return all documents that have at least 1 of the terms in the title, and the rest in the html_source.
If a document has:
title: Holiday, html_source: party food => MATCH
title: Party, html_source: food holiday => MATCH
title: Food, html_source: holiday party => MATCH
title: RANDOM TITLE, html_source: holiday party food => NO MATCH.
This is what I have constructed so far, and it matches documents that have all the terms in the html_source, but NOT in the title, which is not what I want.
{
"query":{
"query_string":{
"query":"holiday party food",
"default_operator":"AND",
"fields":[
"title","html_source"
]
}
},
"sort":[
{
"total_shares":"desc"
}
]
}