Is it possible in elasticsearch to get all documents that contain phrase1 OR phrase2 in a single query? I know to match a phrase, one can use the following query:
"query" : {
"match_phrase" : {
"title" : "rock climbing"
}
}
But how about a case when there are multiple phrases and the goal is to retrieve documents containing either of these phrases.
You can wrap the two
match_phrase
queries in theshould
clause of a bool query :You can perform Query String search
You can specify the AND / OR clause in query or use
default_operator
and just write keywords toquery
parameter. If you want exact phare, just wrap the words to quotes.