# \[inner\_hits\] already contains an entry for key \[xxx\]

**URL:** <https://discuss.elastic.co/t/inner-hits-already-contains-an-entry-for-key-xxx/190853>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [July 17, 2019, 2:40am UTC](https://discuss.elastic.co/t/inner-hits-already-contains-an-entry-for-key-xxx/190853 "2019-07-17T02:40:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuan\_Hong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yuan_hong/32/47234_2.png) [@Yuan\_Hong](https://discuss.elastic.co/u/Yuan_Hong)\
**Post date:** [July 17, 2019, 2:40am UTC](https://discuss.elastic.co/t/inner-hits-already-contains-an-entry-for-key-xxx/190853/1 "2019-07-17T02:40:45Z")

</div>

Hi,

I have an index `worktop_process` with nested field:

```
{
  "orderId": {
    "type": "integer"
  },
  "shipments": {
    "type": "nested",
    "dynamic": "strict",
    "properties": {
      "estimatedReceivingDate": {
        "type": "date"
      },
      "packageId": {
        "type": "keyword"
      },
      "receivingDate": {
        "type": "date"
      }
    }
  }
}

```

And I have the following query to search for all packages that should have been received but not:

> POST \_sql?format=txt  
> {  
> "query": "select orderId, shipments.receivingDate from worktop\_process where shipments.receivingDate is null and shipments.estimatedReceivingDate \< now()"  
> }

It returns an exception:

```
"root_cause": [
  {
    "type": "illegal_argument_exception",
    "reason": "[inner_hits] already contains an entry for key [shipments]"
  }
]

```

But when I removed the nested field from sql return column list, the query works:

> POST \_sql?format=txt  
> {  
> "query": "select orderId from worktop\_process where shipments.receivingDate is null and shipments.estimatedReceivingDate \< now()"  
> }

How is this error to be understood and is there any way work around it?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [July 18, 2019, 7:47am UTC](https://discuss.elastic.co/t/inner-hits-already-contains-an-entry-for-key-xxx/190853/2 "2019-07-18T07:47:16Z")

</div>

@Yuan_Hong thank you for posting the issue you have. Indeed, it's a bug. We were aware of it, but when we discovered it, it was behaving differently: the results of the query were incorrect. Now, there are no results and an error is thrown instead.

I've created an issue [here](https://github.com/elastic/elasticsearch/issues/44544).

---

<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 15, 2019, 7:47am UTC](https://discuss.elastic.co/t/inner-hits-already-contains-an-entry-for-key-xxx/190853/3 "2019-08-15T07:47:23Z")

</div>

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