i using offical elasticsearch npm. in node app creating index using client follows
client.create({ index: orgid, ---------->this dynamic type: "places", body:{} }, function(error, response){ if(error){ } else { } })
i need put mappings above index, have create empty index(index without data) first , have execute put mappings , have put data index.
so have create empty index, in offical elasticsearch client above method(create) written in "post
" method expecting body.
for have give empty body {} above. how can create empty index using official javascript client. please share ideas.
another way go use index templates. idea of index templates let es automatically create missing index whenever needed, i.e. when you're indexing document index name matches pattern , apply pre-defined mapping (+ aliases) new index.
for instance, can create index template this:
curl -xput localhost:9200/_template/template_1 -d '{ "template" : "your_dynamic_index_name_pattern", "settings" : { "number_of_shards" : 1 }, "mappings" : { "places" : { // mapping definition of places type } } }'
when that's done, anytime index new document (e.g. using client.create()
example above) index name matches pattern, es create index automatically , put mapping, before indexing document.
Comments
Post a Comment