Reputation: 524
I want to search documents which match at least two key words using terms query like this:
{
"query": {
"terms": {
"title": ["java","编程","思想"],
"minimum_match": 2
}
},
"highlight": {
"fields": {
"title": {}
}
}
}
It returns "terms query does not support minimum_match".What's wrong with my query?
Upvotes: 1
Views: 4578
Reputation: 217294
The correct name was minimum_should_match
and that setting has been deprecated in ES 2.0.
What you can do instead is to use a bool/should
query with three term
queries and the minimum_should_match
setting for bool/should
queries:
{
"query": {
"bool": {
"minimum_should_match": 2,
"should": [
{
"term": {
"title": "java"
}
},
{
"term": {
"title": "编程"
}
},
{
"term": {
"title": "思想"
}
}
]
}
},
"highlight": {
"fields": {
"title": {}
}
}
}
Upvotes: 2