# "index\_out\_of\_bounds\_exception

**URL:** <https://discuss.elastic.co/t/index-out-of-bounds-exception/203375>\
**Category:** Elasticsearch\
**Created:** [October 14, 2019, 3:40am UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/203375 "2019-10-14T03:40:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RamyaGowda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramyagowda/32/27440_2.png) [@RamyaGowda](https://discuss.elastic.co/u/RamyaGowda)\
**Post date:** [October 14, 2019, 3:40am UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/203375/1 "2019-10-14T03:40:59Z")

</div>

Hi,

```
When using scripts in term aggregation i am getting "index_out_of_bounds_exception why is this happening 

```

> {  
> "took" : 22,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 3,  
> "successful" : 2,  
> "skipped" : 0,  
> "failed" : 1,  
> "failures" : [  
> {  
> "shard" : 0,  
> "index" : "my\_index",  
> "node" : "node1",  
> "reason" : {  
> "type" : "script\_exception",  
> "reason" : "runtime error",  
> "script\_stack" : [  
> "java.nio.Buffer.checkIndex(Buffer.java:540)",  
> "java.nio.DirectByteBuffer.get(DirectByteBuffer.java:253)",  
> "org.apache.lucene.store.ByteBufferGuard.getByte(ByteBufferGuard.java:118)",  
> "org.apache.lucene.store.ByteBufferIndexInput$SingleBufferImpl.readByte(ByteBufferIndexInput.java:385)",  
> "org.apache.lucene.util.packed.DirectReader$DirectPackedReader8.get(DirectReader.java:145)",  
> "org.apache.lucene.codecs.lucene70.Lucene70DocValuesProducer$19.ordValue(Lucene70DocValuesProducer.java:865)",  
> "org.apache.lucene.index.SingletonSortedSetDocValues.advanceExact(SingletonSortedSetDocValues.java:83)",  
> "org.elasticsearch.index.fielddata.FieldData$10.advanceExact(FieldData.java:345)",  
> "org.elasticsearch.index.fielddata.ScriptDocValues$BinaryScriptDocValues.setNextDocId(ScriptDocValues.java:635)",  
> "org.elasticsearch.index.fielddata.ScriptDocValues$Strings.setNextDocId(ScriptDocValues.java:670)",  
> "org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",  
> "org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)",  
> """  
> if(doc['beat.hostname.keyword'].value== "hostname"){
> 
> """,  
> " ^---- HERE"  
> ],  
> "script" : """  
> if(doc['beat.hostname.keyword'].value== "hostname"){  
> return true;  
> }  
> """,  
> "lang" : "painless",  
> "caused\_by" : {  
> "type" : "index\_out\_of\_bounds\_exception",  
> "reason" : "index\_out\_of\_bounds\_exception: null"  
> }  
> }  
> }  
> ]  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : 0.0,  
> "hits" :   
> },  
> "aggregations" : {  
> "host\_wise" : {  
> "doc\_count\_error\_upper\_bound" : 0,  
> "sum\_other\_doc\_count" : 0,  
> "buckets" :   
> }  
> }  
> }

Seeking Help !!!

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 14, 2019, 12:02pm UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/203375/2 "2019-10-14T12:02:34Z")

</div>

is it possible that not all of the documents you queried do contain the field you specified? Can you create a fully reproducible example, including index and document creation plus the full query?

---

<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:** [November 11, 2019, 12:02pm UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/203375/3 "2019-11-11T12:02:38Z")

</div>

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