Index_out_of_bounds_exception: null


(Vipul Tyagi) #1

I am running below Query :-

GET /index_prod_v2*/_search
{
"size": 0,
"query": {
"bool": {
"must": [
{
"range":{
"time": {
"gte": "2018-11-01T02:30:00.000Z",
"lte": "2018-11-02T05:30:01.000Z"
}
}
}
]
}
},
"aggs": {
"Level1_groupByCompetitor": {
"composite": {
"size": 1000,
"sources": [
{
"fieldName1": {
"terms": {
"field": "fieldName1"
}
}
},
{
"fieldName2": {
"terms": {
"field":"fieldName2"
}
}
}
]
},
"aggs": {
"distinct_count": {
"scripted_metric": {
"init_script": """
params._agg.map = [:];
""",
"map_script": """
if (!params._agg.map.containsKey(doc.fieldName3.value)) {
params._agg.map[doc['sku'].value] = 1;
}
""",
"reduce_script": """
def reduce = [:];
for (agg in params._aggs) {
for (entry in agg.map.entrySet()) {
if (!reduce.containsKey(entry.getKey())) {
reduce[entry.getKey()] = entry.getValue();
}
}
}
return reduce.size();
"""
}
}
}
}
}
}

which is throwing below error :-

{
"took": 998,
"timed_out": false,
"_shards": {
"total": 3568,
"successful": 3567,
"skipped": 3560,
"failed": 1,
"failures": [
{
"shard": 0,
"index": "index_prod_v2_y2018_w44_m11_d1",
"node": "Siz6c8KYROyrnaHpqhTRRg",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"java.nio.Buffer.checkIndex(Buffer.java:546)",
"java.nio.DirectByteBuffer.getShort(DirectByteBuffer.java:594)",
"org.apache.lucene.store.ByteBufferGuard.getShort(ByteBufferGuard.java:123)",
"org.apache.lucene.store.ByteBufferIndexInput$SingleBufferImpl.readShort(ByteBufferIndexInput.java:400)",
"org.apache.lucene.util.packed.DirectReader$DirectPackedReader16.get(DirectReader.java:185)",
"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:423)",
"org.elasticsearch.index.fielddata.ScriptDocValues$BinaryScriptDocValues.setNextDocId(ScriptDocValues.java:520)",
"org.elasticsearch.index.fielddata.ScriptDocValues$Strings.setNextDocId(ScriptDocValues.java:555)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:39)",
"params._agg.map[doc['field3'].value] = 1; \n }",
" ^---- HERE"
],
"script": """
if (!params._agg.map.containsKey('doc.field3.value')) {
params._agg.map[doc['field3'].value] = 1;
}
""",
"lang": "painless",
"caused_by": {
"type": "index_out_of_bounds_exception",
"reason": "index_out_of_bounds_exception: null"
}
}
}
]
},
"hits": {
"total": 145639,
"max_score": 0,
"hits":
},
"aggregations": {
"Level1_groupByCompetitor": {
"buckets": [
{
"key": {
"field1": "360Buy",
"field2": 3240
},
"doc_count": 487,
"distinct_count": {
"value": 394
}
},
{
"key": {
"field1": "360Buy",
"field2": 3240
},
"doc_count": 763,
"distinct_count": {
"value": 606
}
},
}

The Same query works with terms aggregation while it fails with composite Aggregation. Elastic Search Version is 6.5


(system) closed #2

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