Reputation: 2351
In the Elasticsearch documentation, it says the "Or Query" is deprecated and to use the "bool" query instead: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-or-query.html
But I'm not sure how to make a logical "OR" using the "bool" query. I tried:
query: {
bool: {
must: [
{ match: { title: 'some title'}},
{ match: { author: 'some author'}}
]
}
}
This matches the title being 'some title' AND the author being 'some author', but how do I convert this into an OR express? Like I want it to match the title being 'some title' OR the author being 'some author'. Thanks!
Upvotes: 2
Views: 3904
Reputation: 4733
Just replace you must with should and add the operator:
query: {
bool: {
should: [
{ match: { title: {query:'some title', operator: 'AND'}},
{ match: { author: {query: 'some author', operator: 'AND'}}
]
}
}
Upvotes: 6