Skip to content

Instantly share code, notes, and snippets.

@tamros
Created July 10, 2018 09:45
Show Gist options
  • Save tamros/c6571e5f582cb921bcddb7ab5988089c to your computer and use it in GitHub Desktop.
Save tamros/c6571e5f582cb921bcddb7ab5988089c to your computer and use it in GitHub Desktop.
Examples of null values
#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