如何在弹性搜索中更新嵌套类型?

时间:2014-06-10 18:54:34

标签: elasticsearch

想象一下,我有一个包含问题的文档,并且作为嵌套类型添加了所有答案。见下面的例子。

我有以下问题:

我如何更新其中一个答案?我知道有更新api,但我找不到一种方法来找到例如id为88的答案,然后更改这个答案的文本。

{
   "_index": "customer",
   "_type": "question",
   "_id": "8",
   "_score": 1,
   "_source": {
      "id": 8,
      "title": "Question title",  
      "content": "The question text itself",              
      "answers": [
         {
            "answer_id": 42,                     
            "text": "Answer text 1"
         },
         {
            "answer_id": 88,                    
            "text": "Answer text 2"
         },
         {
            "answer_id": 79,                     
            "text": "Answer text 3"
         },
         {
            "answer_id": 80,                    
            "text": "Answer text 4"
         },
         {
            "answer_id": 8,                      
            "text": "Answer text 5"
         }
      ]
   }
}

0 个答案:

没有答案