Skip to main content

Posts

Showing posts from June, 2019

append values to an array in elasticsearch

PUT updateindextest/type1/1 {     "counter" : 1,     "roka" : ["red"] } PUT updateindextest/type1/2 {     "counter" : 2,     "roka" : ["sdf"] } POST /updateindextest/type1/_update_by_query?pretty {   "script": { "inline": "ctx._source.roka.add(params.hits)", "params": {"hits": "pila"}   },   "query": { "match_all": {} } } GET updateindextest/_search?pretty {   "query": {     "match_all": {}   } }

add new multiple fields to elasticsearch index

Update by Query POST testindex_script_en/_update_by_query {   "script": {     "source" : "ctx._source.category_id = '111' ;  ctx._source.category_value = 'category1'; ctx._source.slug = 'file_slug' ;  ctx._source.tag_ids= [1,2,3] ; ctx._source.tag_values = ['t1','t2', 't2'] ; ctx._source.created_time = '2019-05-28 12:53:11' ; ctx._source.file = '/home/testdir' "   } }

Add new field to the document in elasticsearch

GET updateindextest/_search {   "query": {     "match_all": {}   } } PUT updateindextest/type1/1 {     "counter" : 1,     "tags" : ["red"] } PUT updateindextest/type1/2 {     "counter" : 2,     "tags" : ["sdf"] } POST test/type1/all/_update {     "doc" : {         "name" : "new_name"     } }