# Handling of null and \[\] (empty list)

**URL:** <https://discuss.elastic.co/t/handling-of-null-and-empty-list/330720>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql, eql-elastic-query-language\
**Created:** [April 25, 2023, 9:24am UTC](https://discuss.elastic.co/t/handling-of-null-and-empty-list/330720 "2023-04-25T09:24:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nguyen\_huy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nguyen_huy/32/120179_2.png) [@nguyen\_huy](https://discuss.elastic.co/u/nguyen_huy)\
**Post date:** [April 25, 2023, 9:24am UTC](https://discuss.elastic.co/t/handling-of-null-and-empty-list/330720/1 "2023-04-25T09:24:01Z")

</div>

Hi everybody, I am very new to Elasticsearch and I have a question regarding the handling of `null` and `[]` (empty list) values. Specifically, in my `dummy` index example, I have a document as follows

```auto
{
        "hits": [
            {
                "_index": "dummy",
                "_type": "_doc",
                "_id": "4c9bc4adbd5f572d708428f3df4dbf55",
                "_score": 17.805637,
                "_source": {
                    "id": 81863,
                    "created_at": "2022-06-14 10:23:31",
                    "updated_at": "2022-06-14 10:23:31",
                    "meta_data": "",
                    "acl": {
                        "species": null,
                        "roles": null, <--- null value
                        "tools": null
                    },
                    "category": ""
                }
            }
        ]
    }
}

```

Here, it is noticeable that the field `acl.roles` is `null`. Additionally, in the same index, there is another document which looks like this

```auto
{
        "hits": [
            {
                "_index": "dummy",
                "_type": "_doc",
                "_id": "10a0a66bf7b60ed28e1ced36bd59934a",
                "_score": 15.609104,
                "_source": {
                    "id": 65690,
                    "created_at": "2020-10-02 09:46:00",
                    "updated_at": "2020-10-02 09:46:00",
                    "meta_data": "a:0:{}",
                    "acl": {
                        "species": [],
                        "roles": [], <--- empty list
                        "tools": []
                    },
                    "category": "PERSONAL"
                }
            }
        ]
    }
}

```

So in the `dummy` index, the field `acl.roles` can have either a `null` value or an `[]` (empty list) value. Could you guys please explain to me:

- What is the difference between `null` and `[]` in Elasticsearch?
- Is it possible to count the number of documents that have `acl.roles=null` and `acl.roles=[]`? If so, what is the difference between the two queries? I try to do a query like below but I don't really understand how Elasticsearch handle these stuff ??

```auto
GET dummy/_count
{
  "query": {
    "bool": {
      "must_not": {
        "exists": {
          "field": "acl.roles"
        }
      }
    }
  }
}

```

If I misunderstand something, please, point it out for me, I really appreciate that.

Thank you guys !!!

---

<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:** [May 23, 2023, 9:24am UTC](https://discuss.elastic.co/t/handling-of-null-and-empty-list/330720/2 "2023-05-23T09:24:11Z")

</div>

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