elasticsearch - ElasticSearch-如何在文档数组中编辑字段

标签 elasticsearch

我的ElasticSearch索引中有一个文档,如下所示:

{
 "_index": "nm_doc",
                "_type": "nm_doc",
                "_id": "JRPXqmQBatyecf67YEfq",
                "_score": 0.86147696,
                "_source": {
                    "text": "A 29-year-old IT professional from Bhopal was convicted and sentenced to life imprisonment by an Additional Sessions Court in Pune on Wednesday for the rape and brutal murder of a woman in 2008, after she had refused his advances. Watch What Else is Making News The court found Manu Mohinder Ebrol, who worked in the same firm as the girl, of raping and killing the woman after stabbing her 18 times on the night of October 20, 2008, in her rented apartment. After committing the crime, Ebrol had fled to Bhopal. He was arrested later by Pune Police. The prosecution examined 26 witnesses for the case and forensic evidence such as call details and medical records also proved crucial. For all the latest Pune News , download Indian Express App",
                    "entities": [
                        {
                            "name": "Mohinder Ebrol"
                        },
                        {
                            "name": "Sessions Court"
                        },
                        {
                            "name": "Pune Police"
                        },
                        {
                            "name": "Pune News"
                        },
                        {
                            "name": "Indian Express"
                        }
                    ]
}

如果我只想将该数组(Mohinder Ebrol)中的名字编辑为Manu Ebrol,我将如何通过API调用来实现?我需要传递整个数组来更新一个名称吗?

最佳答案

我已经通过文档弄清楚了:

call 网址为:

POST http://elastichost:9200/indexname/_doc/JRPXqmQBatyecf67YEfq/_update?pretty

主体看起来像这样(是的,您必须提供整个数组):
{
  "doc": { "entities": [
            {
                "name": "Manu Ebrol"
            },
            {
                "name": "Sessions Court"
            },
            {
                "name": "Pune Police"
            },
            {
                "name": "Pune News"
            },
            {
                "name": "Indian Express"
            }
        ] }
}

希望这可以在将来对某人有所帮助。

关于elasticsearch - ElasticSearch-如何在文档数组中编辑字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53306219/

相关文章:

python - 使用 Python 连接到 AWS Elasticsearch 实例

elasticsearch - ElasticSearch集群复制

Elasticsearch 合并文档作为响应

elasticsearch - 自定义停用词分析器无法正常运行

elasticsearch - 部分动态映射

elasticsearch - Fluentd Elasticsearch Kibana记录动态索引GEOPOINT映射

elasticsearch - 获取ES中的所有翻转索引

elasticsearch - 造成原因:java.lang.NoSuchMethodError:org.elasticsearch.rest.BaseRestHandler

elasticsearch - Elastic Cloud on Kubernetes 更改服务器的配置

elasticsearch - 为什么Elasticsearch术语存储桶大小会影响内部反向嵌套聚合的doc_count?