# Filter to include if value is null or doesn't exist

**URL:** <https://discuss.elastic.co/t/filter-to-include-if-value-is-null-or-doesnt-exist/279203>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [July 20, 2021, 8:07pm UTC](https://discuss.elastic.co/t/filter-to-include-if-value-is-null-or-doesnt-exist/279203 "2021-07-20T20:07:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbrimmer83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbrimmer83/32/52975_2.png) [@mbrimmer83](https://discuss.elastic.co/u/mbrimmer83)\
**Post date:** [July 20, 2021, 8:07pm UTC](https://discuss.elastic.co/t/filter-to-include-if-value-is-null-or-doesnt-exist/279203/1 "2021-07-20T20:07:18Z")

</div>

I want to filter the document if the field is null or empty. I haven't found a way to do this in AppSearch and don't see it mentioned in the docs. Is there a way to accomplish this? Does AppSearch use the Elastic `null_value` field when no value is insert in the document?

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [July 21, 2021, 1:48pm UTC](https://discuss.elastic.co/t/filter-to-include-if-value-is-null-or-doesnt-exist/279203/2 "2021-07-21T13:48:37Z")

</div>

To my knowledge there is no way to do an "exists" filter like in Elasticsearch. Can you do something like the following?

```auto
{
  "query": "parks",
  "filters": {
"filters" : {
    "all": {
      "any": [
          { "some_field": "" },
          { "some_field": null }
        ]
      }
    }
  }
}'

```

This still wouldn't account for all of the scenarios an Elasticsearch "exist" does ([Exists query | Elasticsearch Guide [7.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html#exists-query-top-level-params)), but it might get you close.

Unfortunately, your best bet with App Search is probably to pre-process your data to have consistent "empty" values (like "", for example).

---

<div class="post-metadata">

**Author:** ![mbrimmer83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbrimmer83/32/52975_2.png) [@mbrimmer83](https://discuss.elastic.co/u/mbrimmer83)\
**Post date:** [July 21, 2021, 3:21pm UTC](https://discuss.elastic.co/t/filter-to-include-if-value-is-null-or-doesnt-exist/279203/3 "2021-07-21T15:21:53Z")

</div>

We have decided to go with an `EMPTY` constant in the data processing step and then filter on that.

Thanks @JasonStoltz

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 18, 2021, 3:22pm UTC](https://discuss.elastic.co/t/filter-to-include-if-value-is-null-or-doesnt-exist/279203/4 "2021-08-18T15:22:14Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
