Elasticsearch Insert single key if not exists, without affecting other keys -
in of documents, have key present school. document is:
{ "id" : "123", "name" : "robert", "school" : "public" } now, school not present in documents. want insert school key in documents not present default string.
i using elasticsearch version number 2.4.5. how can it? looking @ bulk update?
i use update query api this. can search documents don't have school field , set whatever default value wish:
post your-index/your-type/_update_by_query { "query": { "bool": { "must_not": { "exists": { "field": "school" } } } }, "script": { "inline": "ctx._source.school = 'dummy'" } } note need enable dynamic scripting , restart es server.
Comments
Post a Comment