I try to learn Elasticsearch to add it in my Rails app.
I want to perform a multi_match query into 2 fields (as if they were just a single field) and also have a filter to another field (status) that must be equal to 1.
let response = Wine.search({
query: {
multi_match: {
query: "test",
fields: ["winery", "name"]
},
bool: {
must: {
term: { status: 1 }
},
should: [],
minimum_should_match: 1
}
}
})
The error is:
"fields\":[\"winery\",\"name\"]},\"bool\":{\"must\":{\"term\":{\"status\":1}},\"should\":[],\"minimum_should_match\":1}}}]]]; nested: ElasticsearchParseException[Expected field name but got START_OBJECT \"bool\"]; }]","status":400}
What is wrong in the request ? How to perform a multi_match AND a BOOL together ?
Best Answer
Use a filtered query:
Same query for Elasticsearch 5: