Trying to find the path to the nested found text

What I need that I have NOT figured out
I would like to get the path(s) to the found text. Where the path would be
book name -> chapter number -> verse number (which is a sibling to verses.text)

What I did figure out how to do was to return the text highlighted using 'highlight'

QUERY

GET /bible-book/_search
{
  "_source": false, 
  "query": {
    "nested": {
      "path": "chapters",
      "query": {
        "nested": {
          "path": "chapters.verses",
          "query": {
            "match": {
              "chapters.verses.text": "consolation"
            }
          }
        }
      }
    }
  }
}

MAPPING

{
  "bible-book": {
    "mappings": {
      "properties": {
        "book": {
          "type": "text"
        },
        "chapters": {
          "type": "nested",
          "properties": {
            "chapter": {
              "type": "integer"
            },
            "verses": {
              "type": "nested",
              "properties": {
                "text": {
                  "type": "text"
                },
                "verse": {
                  "type": "integer"
                }
              }
            }
          }
        }
      }
    }
  }
}

found it, I can use inner_hits,

POST /bible-book/_search
{
  "_source": false, 
  "query": {
    "nested": {
      "path": "chapters.verses",
      "query": {
        "match": {
          "chapters.verses.text": "consolation"
        }
      },
      "inner_hits": {}
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.