In some of my documents, I have a key present as school
. Say the document is:
{
"id" : "123",
"name" : "Robert",
"school" : "Public"
}
Now, school
is not present in all documents. I want to insert school
key in all documents where it is not already present with a default String.
I am using Elasticsearch version number 2.4.5
. How can I do it? Am I looking at a bulk update?
I would clearly use the update by query API for this. You can search for all documents that don't have the
school
field and set it to whatever default value you wish:Note that you need to enable dynamic scripting and restart your ES server.