更新查询未反映在索引上

编程入门 行业动态 更新时间:2024-10-08 03:42:05

更新查询未反映在<a href=https://www.elefans.com/category/jswz/34/1771159.html style=索引上"/>

更新查询未反映在索引上

我正在尝试更新索引,但是它没有得到更新,就像它在控制台日志中显示的那样,它已更新但没有反映在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);

在函数中传递此数据

    {
    isBase64Encoded: false,
    statusCode: 200,
    statusDescription: '200 OK',
    headers: {
        'Set-cookie': 'cookies',
        'Access-Control-Allow-Headers': '*',
        'Access-Control-Allow-Origin': '',
        'Access-Control-Allow-Methods': '*',
        'Content-Type': 'application/json'
    },
    body: '{"error":null,"res":{ producers: [], writers: [ '34422' ], createdBy: 'Joe', _id: 3467288288282, alternate: [ { is_main: false, sort_order: 1, _id: 23, alternate_title_id: 23 }, { is_main: true, sort_order: 0, _id: 23, alternate_title_id: 23 } ], titles: [ { _id: 21, title_id: sadadsadadsdsd } ], projectName: "Project Example", __v: "36"}}',
    id: undefined
}
回答如下:

您的更新电话不正确。应该是这样的:

const result = await client.update({
   index: constants.searchIndexes.project,
   type: "project",
   id: project.titles.title_id,
   refresh: 'true',
   body: {
     doc: project
   }
});
return result;

更多推荐

更新查询未反映在索引上

本文发布于:2024-05-06 18:15:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1753654.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!