I have a mapping, like this
{
"properties": {
"id": {
"type": "keyword"
},
"name": {
"type": "keyword"
}
}
}
about name
field, in my original data the name
can be empty ""
.
I have two choose to put the doc to ES:
{
"id" : 6 ,
"name" : ""
}
or
{
"id" : 6 ,
"name" : null
}
I don't need to search data like name == "" or name != "" or name == null or name != null.
I saw that a mount of empty values
will cause the performance problem somewhere else. And saw that null value
will not be index and search. So I want to put null field.
Is there any difference in my use case ?
CodePudding user response:
A field with an empty ""
string value will yield true to an exists
query, which means that even if your value doesn't really contain a value, for Elasticsearch it does.
The only way to tell ES that your field doesn't contain a value is by assigning null.
CodePudding user response:
An empty string is a string instance of zero length, whereas a null string has no value at all.