从内部匹配中检索查询的匹配嵌套文档周围的多个嵌套文档

时间:2020-10-15 07:32:18

标签: elasticsearch elasticsearch-dsl

有没有一种方法可以在同一嵌套映射中围绕匹配的嵌套文档检索多个嵌套文档。例如,在此文档中:

{
  "Book_Name": "Name of the Wind",
  "Chapters": [
    {
      "Chapter ID": 1,
      "Gist": "some_text_1"
    },
    {
      "Chapter ID": 2,
      "Gist": "some_text_2"
    },
    {
      "Chapter ID": 3,
      "Gist": "some_text_3"
    },
    {
      "Chapter ID": 4,
      "Gist": "some_text_4"
    },
    {
      "Chapter ID": 5,
      "Gist": "some_text_5"
    }
  ]
}

在嵌套“章节”字段的此文档中,假设我的查询将嵌套文档与“章节ID” 3匹配,那么我想检索具有ID {n-1,n + 1}个文档的章节,即我想要检索章节ID { 2,3,4}也嵌套文档。有办法吗?

0 个答案:

没有答案