How to fix ElasticSearch '[match] query doesn't support multiple fields, found [...] and [...]'
Problem:
You want to run an ElasticSearch query like
{
"query": {
"match" : {
"one_field" : "one_value",
"another_field": "another_value"
}
}
}
but you only see an error message like
elasticsearch.exceptions.RequestError: RequestError(400, 'parsing_exception', "[match] query doesn't support multiple fields, found [one_field] and [another_field]")
Solution
Match queries only support one field. You should use a bool
query with a must
clause containing multiple match
queries instead:
{
"query": {
"bool": {
"must": [
{"match": {"one_field" : "one_value"}},
{"match": {"another_field" : "another_value"}},
]
}
}
}