Versions: 3.3
Describe the issue: I created a index that has _field_names enabled and has a field with a null_value configured. The Field names documentation says that
“The
_field_namesfield indexes field names that contain non-null values”
So I indexed a null value, but when searching with the exists clause I get hits with null values.
This shouldn’t happen, it’s to be expected that configured null_valued fields retain the same meaning as they were really null, thus being treated as non-existent as the documentation suggest.
Minimal Reproducible Example:
PUT example
{
"mappings": {
"_field_names": {
"enabled": true
},
"properties": {
"exampleField": {
"type": "long",
"null_value": 0
}
}
}
}
PUT example/_doc/1
{
"exampleField": null
}
POST example/_search
{
"query": {
"bool": {
"must": [
{"exists": {"field": "exampleField"}}
]
}
}
}
Executing this example you see that the document will be returned even though it’s value is null, contradicting the cited expected behavior.