# Null valued fields are treated as existing

**URL:** https://forum.opensearch.org/t/null-valued-fields-are-treated-as-existing/27622
**Category:** OpenSearch
**Created:** [December 16, 2025, 4:58pm UTC](https://forum.opensearch.org/t/null-valued-fields-are-treated-as-existing/27622 "2025-12-16T16:58:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sousu](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@sousu](https://forum.opensearch.org/u/sousu)
#### Post date: [December 16, 2025, 4:58pm UTC](https://forum.opensearch.org/t/null-valued-fields-are-treated-as-existing/27622/1 "2025-12-16T16:58:47Z")

</div>

**Versions** : 3.3

**Describe the issue** : I created a index that has \_field\_names enabled and has a field with a [null\_value](https://docs.opensearch.org/latest/mappings/mapping-parameters/null-value/) configured. The [Field names](https://docs.opensearch.org/latest/mappings/metadata-fields/field-names/) documentation says that

> “The `_field_names` field 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** :

```json
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.

---

<div class="post-metadata">

### Author: ![pablo](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/pablo/32/9946_2.png) [@pablo](https://forum.opensearch.org/u/pablo)
#### Post date: [February 17, 2026, 11:18am UTC](https://forum.opensearch.org/t/null-valued-fields-are-treated-as-existing/27622/2 "2026-02-17T11:18:04Z")

</div>

@sousu As per documentation, the result of your repro is expected.  
You’ve used null\_value in the mapping, so the field is always indexed. In that case, the `exist` will always return the document.

The \_field\_names already handle null values, so no need to define null\_value in mapping.  
Just remove it from the mapping and test your scenario again.
