Hi,
I need to add a new field with null default value to all documents in an index.
I know the following query, but how to add a default value to it?
PUT customer/_mapping/_doc
{
"properties": {
"major": {
"type": "keyword"
}
}
}
Best regards,
Ellie
dadoonet
(David Pilato)
November 6, 2018, 2:06pm
2
I believe it's useless as providing a null value does not add any value...
Why not just updating the schema as you did?
Because later I want to do an update and change those values that are NULL to something else like:
POST customer/_doc/_update_by_query
{
"script": {
"inline": "ctx._source.major = 'student'"
},
"query":
{"bool":
{"must": {"match_all": {}},
"filter": {"term": {"major": "NULL"}}
}
},
"size": 1
}
}
and this query does not work.
Thought maybe that's because the value of the new field is not NULL? you have any other ideas?
dadoonet
(David Pilato)
November 6, 2018, 2:33pm
4
Can't you use a bool -> must_not -> exist query?
system
(system)
Closed
December 4, 2018, 2:54pm
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.