# Elasticsearch inner\_hits query results in ArrayOutOfBoundsException

**URL:** <https://discuss.elastic.co/t/elasticsearch-inner-hits-query-results-in-arrayoutofboundsexception/22978>\
**Category:** Elasticsearch\
**Created:** [March 30, 2015, 11:57am UTC](https://discuss.elastic.co/t/elasticsearch-inner-hits-query-results-in-arrayoutofboundsexception/22978 "2015-03-30T11:57:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marius\_De\_Wit](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@Marius\_De\_Wit](https://discuss.elastic.co/u/Marius_De_Wit)\
**Post date:** [March 30, 2015, 11:57am UTC](https://discuss.elastic.co/t/elasticsearch-inner-hits-query-results-in-arrayoutofboundsexception/22978/1 "2015-03-30T11:57:00Z")

</div>

Hi all! Im currently trying to use the inner\_hits functionality that was  
added in elasticsearch 1.5. Unfortunately, elastic is throwing an  
ArrayOutOfBoundsException when running my query. I would be very grateful  
if someone can have a look and tell me what I am doing wrong, as I feel  
that I have followed the documentation correctly.

Example that produces the problem:

curl -XPOST '[http://localhost:9200/twitter](http://localhost:9200/twitter)'

curl -XPOST '[http://localhost:9200/twitter/\_mapping/tweet](http://localhost:9200/twitter/_mapping/tweet)' -d '  
{  
"tweet": {  
"properties": {  
"comments": {  
"properties": {  
"messages": {  
"type": "nested",  
"properties": {  
"message": {  
"type" : "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}  
}  
}  
}'

curl -XPOST '[http://localhost:9200/twitter/tweet](http://localhost:9200/twitter/tweet)' -d '  
{  
"comments": {  
"messages": [  
{"message": "Nice website"},  
{"message": "Worst ever"}  
]  
}  
}'

curl -XGET '[http://localhost:9200/twitter/tweet/\_search](http://localhost:9200/twitter/tweet/_search)' -d '  
{  
"query": {  
"nested": {  
"path": "comments.messages",  
"query": {  
"match": {"comments.messages.message": "Nice website"}  
},  
"inner\_hits" : {}  
}  
}  
}'

Response:

{"took":54,"timed\_out":false,"\_shards":{"total":5,"successful":4,"failed":1,"failures":[{"index":"twitter","shard":4,"status":500,"reason":"ArrayIndexOutOfBoundsException[-1]"}]},"hits":{"total":1,"max\_score":1.4054651,"hits":[]}}

Note that the query will work if I take "inner\_hits" out.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/917e9889-6552-428d-a84c-1d3b0362bb93%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/917e9889-6552-428d-a84c-1d3b0362bb93%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:23am UTC](https://discuss.elastic.co/t/elasticsearch-inner-hits-query-results-in-arrayoutofboundsexception/22978/2 "2017-07-06T00:23:07Z")

</div>


