# Trying to find the path to the nested found text

**URL:** https://discuss.elastic.co/t/trying-to-find-the-path-to-the-nested-found-text/351752
**Category:** Elasticsearch
**Created:** [January 24, 2024, 8:03pm UTC](https://discuss.elastic.co/t/trying-to-find-the-path-to-the-nested-found-text/351752 "2024-01-24T20:03:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![warrengoldman](https://avatars.discourse-cdn.com/v4/letter/w/d6d6ee/32.png) [@warrengoldman](https://discuss.elastic.co/u/warrengoldman)
#### Post date: [January 24, 2024, 8:03pm UTC](https://discuss.elastic.co/t/trying-to-find-the-path-to-the-nested-found-text/351752/1 "2024-01-24T20:03:04Z")

</div>

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

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

```

MAPPING

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

```

---

<div class="post-metadata">

### Author: ![warrengoldman](https://avatars.discourse-cdn.com/v4/letter/w/d6d6ee/32.png) [@warrengoldman](https://discuss.elastic.co/u/warrengoldman)
#### Post date: [January 24, 2024, 9:50pm UTC](https://discuss.elastic.co/t/trying-to-find-the-path-to-the-nested-found-text/351752/2 "2024-01-24T21:50:15Z")

</div>

found it, I can use inner\_hits,

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

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 21, 2024, 9:51pm UTC](https://discuss.elastic.co/t/trying-to-find-the-path-to-the-nested-found-text/351752/3 "2024-02-21T21:51:09Z")

</div>

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