Best practice for empty fields?


Hi All,

For empty fields, should I use null or ""? What is the best practice? Are they equivalent?


(Jymit Singh Khondhu) #2

can you share more context, perhaps even screenshots?


Sure! For example, lets say that I have an index with user information. There is a field for age (type long). There could be cases where the age is not known. Which value should I use for the age field when inserting the record (null or "")? They both seem to work. I am wondering which one would be better.

PUT users/_doc/1
    "user": "kimchy",
    "age": ""


PUT users/_doc/1
    "user": "kimchy",
    "age": null

(Jymit Singh Khondhu) #4


(Gilad Sh) #5

Can you please explain why this is better?
Will it help with better performance in queries?
How about other options as not adding this field at all or some default value (e.g.: -1) ?

(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.