I have multiple indices to index data from Firebase to Elasticsearch.
I am using client.indices.putTemplate
to put template in the elasticsearch. which is successfully getting saved, but the same is not being used when the indexer starts to index the data.
my indexer uses :
initTemplate(account) {
this.eSClient.indices.putTemplate({
name: account.type,
body: account.template,
}, (error, response) => {
if (error) {
console.error('error while storing template ', error);
} else {
console.log('template stored', response);
}
});
}
account is an object :
account: {
type: 'account',
index: 'accounts',
template: accountsTemplate,
}
finally accountsTemplate is the actual template with the below data:
{
"template": "account*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"account" : {
"properties" : {
"email" : {
"type" : "string"
}
}
}
}
}
when I run the indexer, it does not index based on the saved the template, and gives the error as
failed to index accounts/account/ff946b57-517a-4b88-a322-5b590e6a40c9: [index_not_found_exception] no such index, with { resource.type=index_expression
{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index\"
I even see that the template is saved.
curl -XGET localhost:9200/_template/account?pretty
the indexer:
this.elasticSearchClient.index({
index: this.index,
type: this.type,
id: key,
body: data }, (error, response) => {
if (callback) {
callback(error, response);
}
});
References:
using elasticssearch client to create indices
Creating an empty index in elasticsearch in node.js
Where do I put the mapping files for Elasticsearch?