ElasticSearch - как редактировать поле внутри массива документа - PullRequest
0 голосов
/ 14 ноября 2018

У меня есть документ в нашем индексе 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?Нужно ли передавать весь массив, чтобы обновить одно имя?

1 Ответ

0 голосов
/ 14 ноября 2018

Я понял это с помощью документации:

URL-адрес вызова:

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"
            }
        ] }
}

Надеюсь, это поможет кому-то в будущем.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...