# Index\_out\_of\_bounds\_exception

**URL:** <https://discuss.elastic.co/t/index-out-of-bounds-exception/184173>\
**Category:** Elasticsearch\
**Created:** [June 4, 2019, 12:15pm UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/184173 "2019-06-04T12:15:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![darshansh](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@darshansh](https://discuss.elastic.co/u/darshansh)\
**Post date:** [June 4, 2019, 12:15pm UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/184173/1 "2019-06-04T12:15:35Z")

</div>

Hi, getting below error while running painless script in elasticsearch 6.7. Any hint or fix ?

"failures": [  
{  
"shard": 2,  
"index": "mpis\_test",  
"node": "qYRoYv39RZqGrP7iAhukcQ",  
"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.codecs.lucene70.Lucene70DocValuesProducer$10.get(Lucene70DocValuesProducer.java:599)",  
"org.apache.lucene.codecs.lucene70.Lucene70DocValuesProducer$21.nextValue(Lucene70DocValuesProducer.java:1223)",  
"org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData$MultiFloatValues.nextValue(SortedNumericDVIndexFieldData.java:353)",  
"org.elasticsearch.index.fielddata.ScriptDocValues$Doubles.setNextDocId(ScriptDocValues.java:365)",  
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",  
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)",  
"arr = doc['display.passengerTypePrices.total']; int ",  
" ^---- HERE"  
],  
"script": "double adt = 0, cnn = 0, inf = 0; double addTax = 0; if (doc['display.locationId.reservationSystemIdentifier.keyword'].value == params.taxIdentifier) { if(doc['display.qualifiers.tariffTypes.keyword'].value== 'PUBLISHED') addTax = params.Published; else if(doc['display.qualifiers.tariffTypes.keyword'].value== 'NEGO') addTax = params.Nego; else if(doc['display.qualifiers.tariffTypes.keyword'].value== 'CORPORATE\_NEGO' && doc['display.qualifiers.corporateCodes.value.keyword'].value == params.OfficeId) addTax = params.corporate\_Nego; } def arr = doc['display.passengerTypePrices.total']; int arrlen = arr.length; for(int i = 0; i\<arr.length;i++){if(doc['display.passengerTypePrices.passengerType.keyword'][i]=='ADT') adt = arr[(arrlen - 1) - i]; else if(doc['display.passengerTypePrices.passengerType.keyword'][i]=='CNN') cnn = arr[(arrlen - 1) - i]; else if(doc['display.passengerTypePrices.passengerType.keyword'][i]=='INF') inf = arr[(arrlen - 1) - i]; } return (((adt + addTax) params.ADT) + ((cnn + addTax) params.CNN) + ((inf + addTax) \* params.INF));",  
"lang": "painless",  
"caused\_by": {  
"type": "index\_out\_of\_bounds\_exception",  
"reason": null  
}  
}  
}  
]

---

<div class="post-metadata">

**Author:** ![darshansh](https://avatars.discourse-cdn.com/v4/letter/d/8e8cbc/32.png) [@darshansh](https://discuss.elastic.co/u/darshansh)\
**Post date:** [June 5, 2019, 5:54am UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/184173/2 "2019-06-05T05:54:06Z")

</div>

Anybody has any idea about the fix for this ?

---

<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 3, 2019, 5:54am UTC](https://discuss.elastic.co/t/index-out-of-bounds-exception/184173/3 "2019-07-03T05:54:07Z")

</div>

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