Created
July 10, 2018 09:45
-
-
Save tamros/c6571e5f582cb921bcddb7ab5988089c to your computer and use it in GitHub Desktop.
Examples of null values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Values like that will not be considered null | |
POST null_values/_doc | |
{ | |
"user": [ | |
"jane", | |
null | |
] | |
} | |
#or | |
POST null_values/_doc | |
{ | |
"user": "" | |
} | |
POST null_values/_doc | |
{ | |
"user": "null" | |
} | |
POST null_values/_doc | |
{ | |
"user": "None" | |
} | |
#Searching and aggregating in null values | |
#searching for documents the field exist | |
GET null_values/_search | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"exists": { | |
"field": "user" | |
} | |
} | |
] | |
} | |
} | |
} | |
#searching for documents the field doesn't exist | |
GET null_values/_search | |
{ | |
"query": { | |
"bool": { | |
"must_not": [ | |
{ | |
"exists": { | |
"field": "user" | |
} | |
} | |
] | |
} | |
} | |
} | |
#aggregating in null values | |
GET null_values/_search | |
{ | |
"size": 0, | |
"aggs": { | |
"null_agg": { | |
"missing": { | |
"field": "user.keyword" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment