我有多个索引来索引从 Firebase 到 Elasticsearch 的数据。
我正在使用client.indices.putTemplate
将模板放入弹性搜索中。已成功保存,但在索引器开始索引数据时未使用相同的内容。
我的索引器使用:
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 是一个对象:
account: {
type: 'account',
index: 'accounts',
template: accountsTemplate,
}
最后 accountsTemplate 是具有以下数据的实际模板:
{
"template": "account*",
"settings" : {
"number_of_shards" : 1
},
"mappings" : {
"account" : {
"properties" : {
"email" : {
"type" : "string"
}
}
}
}
}
当我运行索引器时,它不会根据保存的模板进行索引,并给出错误为
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\"
我什至看到模板已保存。
curl -XGET localhost:9200/_template/account?pretty
索引器:
this.elasticSearchClient.index({
index: this.index,
type: this.type,
id: key,
body: data }, (error, response) => {
if (callback) {
callback(error, response);
}
});
参考:
使用 elasticssearch 客户端创建索引
在 node.js 中的 elasticsearch 中创建一个空索引我在
哪里放置 Elasticsearch 的映射文件?