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

**URL:** <https://discuss.elastic.co/t/shard-failed-the-data-you-are-seeing-might-be-incomplete-or-wrong/288670>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [November 8, 2021, 7:17pm UTC](https://discuss.elastic.co/t/shard-failed-the-data-you-are-seeing-might-be-incomplete-or-wrong/288670 "2021-11-08T19:17:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ptanguturi](https://avatars.discourse-cdn.com/v4/letter/p/f6c823/32.png) [@ptanguturi](https://discuss.elastic.co/u/ptanguturi)\
**Post date:** [November 8, 2021, 7:17pm UTC](https://discuss.elastic.co/t/shard-failed-the-data-you-are-seeing-might-be-incomplete-or-wrong/288670/1 "2021-11-08T19:17:25Z")

</div>

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  
}  
}

---

<div class="post-metadata">

**Author:** ![stu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stu/32/75063_2.png) [@stu](https://discuss.elastic.co/u/stu)\
**Post date:** [November 15, 2021, 5:08pm UTC](https://discuss.elastic.co/t/shard-failed-the-data-you-are-seeing-might-be-incomplete-or-wrong/288670/2 "2021-11-15T17:08:17Z")

</div>

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.

> [@ptanguturi](#):
>
> No field found for [PreAuthsToProcess] in mapping with types

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

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

```

Or you can [add the mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html) for `PreAuthsToProcess`.

---

<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:** [December 13, 2021, 5:08pm UTC](https://discuss.elastic.co/t/shard-failed-the-data-you-are-seeing-might-be-incomplete-or-wrong/288670/3 "2021-12-13T17:08:56Z")

</div>

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