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

Time:09-06

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.

CodePudding user response:

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)"
  • Related