lovrodoe
lovrodoe

Reputation: 492

Value does not exist or value is null for specific field in Elasticsearch (query_string)

I'm attempting to search for null or non-existant values for specific fields with query_string. My existing query is as follows:

{
    "query": {
        "query_string" : {
            "query" : "stringProperty.keyword:01 AND booleanProperty:false",
            "analyze_wildcard" : false,
            "allow_leading_wildcard": false
        } 
    }
}

Not sure if it's possible, I could not find anything useful in documentation.

Upvotes: 0

Views: 81

Answers (1)

Val
Val

Reputation: 217294

In order to search for a document having a field with a null or non-existent value with query_string you can do it like this:

 "query" : "NOT(_exists_:stringProperty.keyword)"

Upvotes: 1

Related Questions