带节点的弹性搜索能否仅更新特定字段而无需重写?

问题描述 投票:0回答:1

我的文档中的字段如下所示:

_source:
...
"produto_tags" : [
            {
              "id_produto_cor" : "1623153806",
              "tags" : []
            },
            {
             "id_produto_cor" : "875623985732",
             "tags": []
            },
            {...}
...

我需要在此字段上插入另一个对象,而无需重写整个produto_tags

data to be inserted:
             {
             "id_produto_cor" : "312411",
             "tags": []
            },

我的最终文件将如下所示:

_source:
...
"produto_tags" : [
            {
              "id_produto_cor" : "1623153806",
              "tags" : []
            },
            {
             "id_produto_cor" : "875623985732",
             "tags": []
            },
            {
             "id_produto_cor" : "312411",
             "tags": []
            }
]

我正在使用NODE js,我正在使用它,但是它重写了我写的内容:

 const query = { 
      doc: {
        nome_relatorio: nome_relatorio,
        produto_tags: produto_tags,
        referencia_tags: referencia_tags,
      }
    };
    return await esClient.update({
        index: indexName,
        body: query,
        id: id,
        method: 'post',
        type: typeDoc,  
    })
javascript node.js elasticsearch elasticsearch-5
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.