Shard Failed- The data you are seeing might be incomplete or wrong

I am getting below error message. not sure what when wrong and didn't make any changes to index.

script_exception at shard 0index default-2021.11node weAPTkoJTm6njIweWotMLw
Type
script_exception
Reason
runtime error
Script stack
org.Elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)
org.Elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)
if(doc['PreAuthsToProcess'].size() != 0 ){

   ^---- HERE

Script
if(doc['PreAuthsToProcess'].size() != 0 ){
if(doc['totalExecutionTimeInSeconds'].size() != 0){
return doc['totalExecutionTimeInSeconds'].value / doc['PreAuthsToProcess'].value;
}
else{
return 0;
}
}
else{
return 0;
}

Lang
painless
Caused by type
illegal_argument_exception
Caused by reason
No field found for [PreAuthsToProcess] in mapping with types

From the Request Tab:

{
"version": true,
"size": 500,
"sort": [
{
"@timestamp": {
"order": "desc",
"unmapped_type": "boolean"
}
}
],
"aggs": {
"2": {
"date_histogram": {
"field": "@timestamp",
"fixed_interval": "30m",
"time_zone": "America/Chicago",
"min_doc_count": 1
}
}
},
"stored_fields": [
""
],
"script_fields": {
"AveragePreCertCheckExecutionTimeSeconds": {
"script": {
"source": "if(doc['PreAuthsToProcess'].size() != 0 ){\n if(doc['totalExecutionTimeInSeconds'].size() != 0){\n return doc['totalExecutionTimeInSeconds'].value / doc['PreAuthsToProcess'].value;\n }\n else{\n return 0;\n }\n}\nelse{\n return 0;\n}",
"lang": "painless"
}
}
},
"docvalue_fields": [
{
"field": "@timestamp",
"format": "date_time"
},
{
"field": "timeStamp",
"format": "date_time"
}
],
"_source": {
"excludes": []
},
"query": {
"bool": {
"must": [],
"filter": [
{
"match_all": {}
},
{
"range": {
"@timestamp": {
"gte": "2021-11-08T06:00:00.000Z",
"lte": "2021-11-09T05:59:59.999Z",
"format": "strict_date_optional_time"
}
}
}
],
"should": [],
"must_not": []
}
},
"highlight": {
"pre_tags": [
"@kibana-highlighted-field@"
],
"post_tags": [
"@/kibana-highlighted-field@"
],
"fields": {
"
": {}
},
"fragment_size": 2147483647
}
}

Hi @ptanuturi,
If a field is not mapped, it is not available in doc. It seems PreAuthsToProcess is not mapped in one of the indices you're querying, perhaps via an index pattern.

To avoid this error, in addition to checking doc['PreAuthsToProcess'].size() != 0, you should check doc.hasKey('PreAuthsToProcess'):

if(doc.hasKey('PreAuthsToProcess') && doc['PreAuthsToProcess'].size() != 0 )

Or you can add the mapping for PreAuthsToProcess.

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