# Nested Query inner\_hits: why do I only get one under a bool's must?

**URL:** <https://discuss.elastic.co/t/nested-query-inner-hits-why-do-i-only-get-one-under-a-bools-must/130899>\
**Category:** Elasticsearch\
**Created:** [May 7, 2018, 8:02pm UTC](https://discuss.elastic.co/t/nested-query-inner-hits-why-do-i-only-get-one-under-a-bools-must/130899 "2018-05-07T20:02:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerboa](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@jerboa](https://discuss.elastic.co/u/jerboa)\
**Post date:** [May 7, 2018, 8:02pm UTC](https://discuss.elastic.co/t/nested-query-inner-hits-why-do-i-only-get-one-under-a-bools-must/130899/1 "2018-05-07T20:02:06Z")

</div>

Hi all,

I'm trying to use inner\_hits in my bool must query.  
The query is conceptually MUST: [NESTED, NESTED]  
ie, two separate nested queries must match to score a hit.

I believe I always get the second inner\_hits result in my query results, but not the first. It does look like the query hits are matching correctly, just the inner\_hits aren't complete.

Any guidance?

I'm using the Python API, so my body looks like this (it's not quite Json, but it almost is):

```
    {
    'size': 10, 
    'query': {
        'bool': {
            'must': [{
                'nested': {
                    'path': 'attributes', 
                    'score_mode': 
                    'avg', 'inner_hits': {},
                     'query': {'bool': {
                             'must': [{'match': {'attributes.ename': 'n1'}},
                                      {'match': {'attributes.sv': 'v1'}}]}}}}, 
                      {
                 'nested': {
                    'path': 'attributes', 
                    'score_mode': 
                    'avg', 
                    'inner_hits': {},
                    'query': {'bool': {
                            'must': [{'match': {'attributes.ename': 'n2'}},
                                     {'match': {'attributes.sv': 'v2'}}]}}}}]
        }
    }
}
```

---

<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:** [June 4, 2018, 8:02pm UTC](https://discuss.elastic.co/t/nested-query-inner-hits-why-do-i-only-get-one-under-a-bools-must/130899/2 "2018-06-04T20:02:11Z")

</div>

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