# How to get the summation of inner\_hits hits total value

**URL:** <https://discuss.elastic.co/t/how-to-get-the-summation-of-inner-hits-hits-total-value/352022>\
**Category:** Elasticsearch\
**Created:** [January 29, 2024, 5:27pm UTC](https://discuss.elastic.co/t/how-to-get-the-summation-of-inner-hits-hits-total-value/352022 "2024-01-29T17:27:07Z")\
**Posts on this page:** 2\
**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 29, 2024, 5:27pm UTC](https://discuss.elastic.co/t/how-to-get-the-summation-of-inner-hits-hits-total-value/352022/1 "2024-01-29T17:27:07Z")

</div>

Cannot figure out the syntax for aggregations per the doc for this. Would think this type of request is very common...

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

```

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

```

```auto
 "hits": {
    "total": {
      "value": 11,
      "relation": "eq"
    },
    "max_score": 9.562649,
    "hits": [
      {
        "_index": "bible-book",
        "_id": "18",
        "_score": 9.562649,
        "inner_hits": {
          "chapters.verses": {
            "hits": {
              "total": {
                "value": 2, <==== want the summation of this for inner_hits
                "relation": "eq"
              },
              "max_score": 9.7188

```

---

<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 26, 2024, 5:27pm UTC](https://discuss.elastic.co/t/how-to-get-the-summation-of-inner-hits-hits-total-value/352022/2 "2024-02-26T17:27:22Z")

</div>

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