Behebung von ElasticSearch '[match] query doesn't support multiple fields, found [...] and [...]'
English
Deutsch
Problem:
Du möchtest eine ElasticSearch-Abfrage wie diese ausführen
match-query-example.json
{
"query": {
"match" : {
"one_field" : "one_value",
"another_field": "another_value"
}
}
}aber du siehst nur eine Fehlermeldung wie
elasticsearch-error.txt
elasticsearch.exceptions.RequestError: RequestError(400, 'parsing_exception', "[match] query doesn't support multiple fields, found [one_field] and [another_field]")Lösung
Match-Abfragen unterstützen nur ein Feld. Du solltest stattdessen eine bool-Abfrage mit einer must-Klausel verwenden, die mehrere match-Abfragen enthält:
bool-must-multi-match.json
{
"query": {
"bool": {
"must": [
{"match": {"one_field" : "one_value"}},
{"match": {"another_field" : "another_value"}},
]
}
}
}Siehe auch die offizielle Dokumentation zur MultiMatch-Abfrage.
Check out similar posts by category:
Databases, ElasticSearch
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow