# Access inner\_hits response in Apache Hadoop Spark

**URL:** <https://discuss.elastic.co/t/access-inner-hits-response-in-apache-hadoop-spark/309320>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [July 11, 2022, 1:03pm UTC](https://discuss.elastic.co/t/access-inner-hits-response-in-apache-hadoop-spark/309320 "2022-07-11T13:03:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anand\_tripathi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_tripathi/32/107286_2.png) [@anand\_tripathi](https://discuss.elastic.co/u/anand_tripathi)\
**Post date:** [July 11, 2022, 1:03pm UTC](https://discuss.elastic.co/t/access-inner-hits-response-in-apache-hadoop-spark/309320/1 "2022-07-11T13:03:10Z")

</div>

I have an Elasticsearch query that is giving me a response with standard \_source data and some additional response that is inner\_hits matching the nested document of the index. The response is something like below

```auto
{
  "took" : 9,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 5,
      "relation" : "eq"
    },
    "max_score" : 3.638414,
    "hits" : [
      {
        "_index" : "family",
        "_id" : "39684609",
        "_score" : 3.638414,
        "_source" : {...},
        "inner_hits" : {
          "representative.invention_title" : {
            "hits" : {
              "total" : {
                "value" : 1,
                "relation" : "eq"
              },
              "max_score" : 0.089231126,
              "hits" : [
                {
                  "_index" : "family",
                  "_id" : "39684609",
                  "_nested" : {
                    "field" : "representative.invention_title",
                    "offset" : 0
                  },
                  "_score" : 0.089231126,
                  "_source" : {
                    "title" : "Method for making a hammer"
                  }
                }
              ]
            }
          }
        }
      }
        ]
  }
}

```

I want to access that `hits` inside `inner_hits`. I can access source inside the spark dataframe, but not the inner\_hits. I checked out the documentation they support metadata but I couldn't able to find a way to access inner\_hits from metadata

---

<div class="post-metadata">

**Author:** ![Keith\_Massey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keith_massey/32/83666_2.png) [@Keith\_Massey](https://discuss.elastic.co/u/Keith_Massey)\
**Post date:** [July 11, 2022, 1:42pm UTC](https://discuss.elastic.co/t/access-inner-hits-response-in-apache-hadoop-spark/309320/2 "2022-07-11T13:42:24Z")

</div>

Hi @anand_tripathi. I suspect it's not supported based on this comment: [support highlighting and other non \_source headers · Issue #460 · elastic/elasticsearch-hadoop · GitHub](https://github.com/elastic/elasticsearch-hadoop/issues/460#issuecomment-785784933), plus the fact that I don't see any relevant test cases in the source code. Would you mind posting enough to reproduce this (commands to insert data into elasticsearch, plus spark code to query it)?

---

<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:** [August 8, 2022, 1:43pm UTC](https://discuss.elastic.co/t/access-inner-hits-response-in-apache-hadoop-spark/309320/3 "2022-08-08T13:43:09Z")

</div>

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