python - Simple update field in elasticsearch -


i started using elsaticsearch , sense few weeks ago. need bulk update string field in documents of index follows: if string starts "+", update field same value without "+".

old: number: "+212112233" new: number: "212112233"

is there simple way me rest dsl or need use python?

thanks!

if can install update-by-query plugin, there's way it. plugin works giving query matching documents update , script update matching documents.

curl -xpost localhost:9200/your_index/your_type/_update_by_query -d ' {   "query": {     "filtered": {       "filter": {         "script": {           "script": "_source[\"your_field\"].indexof(\"+\") == 0"         }       }     }   },   "script": "ctx._source.your_field = ctx._source.your_field.substring(1);" }' 

note: replace your_index, your_type , your_field respectively index, type , field name.

so, tell plugin update documents containing your_field value starts + (not knowing if your_field analyzed string or not, here directly _source make sure check raw string value indexed) , tell script update each matching document taking substring of value leaving out + sign.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -