templates - How to update dynamic_templates on all existing indices? -


i'm using elasticsearch 5.1 , elasticsearch.js 5.0. have many different applications in production, may have our platform default indices or custom ones. , don't know names. new indices, able add following dynamic_template using indices.puttemplate():

var elasticsearch = require('elasticsearch'); var client = new elasticsearch.client({ /*...*/ }); var params = {    //...   "body" : {     "template":"*",     "settings":{                  "index.mapper.dynamic":true       //...                },     "mappings":{       "_default_":{         "properties":{           //...         },         "dynamic_templates":[{           "template_purchases_inner_fields": {             "path_match":"purchases.*",             "mapping": { "include_in_all": false }           }         }         //, ...         ]       }     }   } }; client.indices.puttemplate(params,function(err,resp){}) 

however, index templates docs

templates applied @ index creation time. changing template have no impact on existing indices

the dynamic templates docs

new templates can appended end of list put mapping api

the put mapping api has examples, none of fit scenario. answer using indices.putmapping() helpful, not necessary. time!


[edited on 8-21-2017, solar eclipse day] code tried change through js api:

var dynamictemplates = [{     "template_purchases_inner_fields": {       "path_match": "purchases.*",       "mapping": { "include_in_all": false}     }   }   //...   ];  params = { body:  {   "dynamic_templates": dynamictemplates   }}; params.index = "_all"; params.type = "_default_"; //... client.indices.putmapping(params,function(err,resp){}) 

and code through linux curl, w/ properties field removed. please notice should re-add here other templates not override previous ones:

curl -xput http://localhost:9200/_all/_default_/_mapping -d "{\"_default_\":{\"dynamic_templates\":[{\"template_purchases_inner_fields\":{\"mapping\":{\"include_in_all\":false},\"path_match\":\"purchases.*\"}}]}}" 

checking on elasticsearch-head, on both cases, mapping updated on existing indices too, if worked. however, include_in_all=false behavior not achieved, meaning still see results on searching _all on records containing inner objects under purchases.* on existing indices.


related items:

the current answer cannot apply existing index, based on index templates docs:

templates applied @ index creation time. changing template have no impact on existing indices


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -