Search code examples
elasticsearchelastic-stackelk

Empty field request


so I have a GET request and I need to filter documents with empty fields, is there any way I can do that in ES because I know you can't search for empty fields, will a filter work the same as search? this document field is actually a 2D array in Elastic search.

curl -X GET -H "Content-Type: application/json" "localhost.blahblah/" -d '{"query":{ "bool": {"filter": {"terms":{ "documents":[ "" ] } } } }}'

curl -X GET -H "Content-Type: application/json" "my_index/" -d '{"query":{ "bool": {"filter": {"terms":{ "documents":[ "" ] } } } }}'


Solution

  • Try the code bellow:

    {
      "query": {
        "bool": {
          "must_not": [
            {
              "wildcard": {
                "documents": {
                  "value": "*"
                }
              }
            }
          ]
        }
      }
    }