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

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -