How to fix ElasticSearch 'no [query] registered for [missing]'
Problem:
You are trying to run an ElasticSearch query like
{
"query": {
"missing" : { "field" : "myfield" }
}
}
to find documents that do not have myfield
.
However you only see an error message like this:
elasticsearch.exceptions.RequestError: RequestError(400, 'parsing_exception', 'no [query] registered for [missing]')
Solution
As the ElasticSearch documentation tells, us, there is no missing
query! You instead need to use an exists
query inside a must_not
clause:
{
"query": {
"bool": {
"must_not": {
"exists": {
"field": "myfield"
}
}
}
}
}