最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Elasticsearch更新未反映在Elasticsearch索引上

运维笔记admin17浏览0评论

Elasticsearch更新未反映在Elasticsearch索引上

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;
发布评论

评论列表(0)

  1. 暂无评论