Most elegant way to -OR- two phrase queries together


(Josh P) #1

I have a schema with a single field named "keywords_search" whose value is
an array of phrases. I would like to perform a the most efficient possible
search_type=count query that returns all documents whose keyword_search
field contains either phrase "ford mustang" or "ford f150", ideally with
caching. I don't need any ranking/scoring. Here's the query I've come up
with so far:

{
"query": {
"constant_score": {
"filter": {
"or": [{
"query": {
"text_phrase": {
"keywords_search": "ford mustang"
}
}
}, {
"query": {
"text_phrase": {
"keywords_search": "ford f150"
}
}
}
]
}
}
}
}

Is there a more concise query to achieve this? I'm currently using the
default tokenizer/analyzer, but I can change that if necessary. Here's a
sample matching document:

{
"keywords_search": [ "I want a ford mustang", "who let the dogs out" ]
}

Thanks!

--


(system) #2