Elasticsearch更新未反映在Elasticsearch索引上
我正在尝试更新索引,但是它没有得到更新,就像它在控制台日志中显示的那样,它已更新但没有反映在elasticsearch查询中,如果我在控制台上检查它是否已更新,而不是在elasticseach查询中。谁能帮助我我错了?
updateProjectIndex = async (project) => {
try{
client.update({
index: constants.searchIndexes.project,
type: "project",
id: project.titles.title_id,
refresh: 'true',
body: project,
});
}
catch(e) {
console.log(e);
}
}
这是从其他文件中调用。
var elasticData= JSON.parse(result.body);
elasticData = elasticData.res;
console.log(elasticSearch_common);
elasticSearch_common.updateProjectIndex(elasticData);
回答如下:您的更新电话不正确。应该是这样的:
const result = await client.update({
index: constants.searchIndexes.project,
type: "project",
id: project.titles.title_id,
refresh: 'true',
body: project,
});
return result;