# Exception using painless script

**URL:** <https://discuss.elastic.co/t/exception-using-painless-script/87223>\
**Category:** Elasticsearch\
**Created:** [May 26, 2017, 9:47am UTC](https://discuss.elastic.co/t/exception-using-painless-script/87223 "2017-05-26T09:47:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xam](https://avatars.discourse-cdn.com/v4/letter/x/bb73d2/32.png) [@xam](https://discuss.elastic.co/u/xam)\
**Post date:** [May 26, 2017, 9:47am UTC](https://discuss.elastic.co/t/exception-using-painless-script/87223/1 "2017-05-26T09:47:37Z")

</div>

Hi,

I use a simple painless script "doc['myFieldName'].value" for my aggregation with ES 5.3 and I get the following exception:

> java.lang.AssertionError: docid=-1,maxDoc=29  
> at \_\_randomizedtesting.SeedInfo.seed([9BC01C49C008CD2B]:0)  
> at org.apache.lucene.index.AssertingLeafReader$AssertingRandomAccessOrds.setDocument(AssertingLeafReader.java:554)  
> at org.elasticsearch.index.fielddata.FieldData$8.setDocument(FieldData.java:403)  
> at org.elasticsearch.index.fielddata.ScriptDocValues$Strings.setNextDocId(ScriptDocValues.java:93)  
> at org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:92)  
> at org.elasticsearch.painless.Executable$Script.execute(doc['ICUZ'].value:5)  
> at org.elasticsearch.painless.ScriptImpl.run(ScriptImpl.java:123)  
> at org.elasticsearch.search.aggregations.support.ValuesSource$WithScript$BytesValues.setDocument(ValuesSource.java:478)  
> at org.elasticsearch.search.aggregations.bucket.terms.StringTermsAggregator$1.collect(StringTermsAggregator.java:81)  
> at org.elasticsearch.search.aggregations.LeafBucketCollector.collect(LeafBucketCollector.java:82)  
> at org.apache.lucene.search.MultiCollector$MultiLeafCollector.collect(MultiCollector.java:174)  
> at org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:221)  
> at org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:172)  
> at org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)

The field exists : I can see in debug mode that ES is able to read the field value for the current document but it fails to collect the doc id (it tries to collect "-1" as a docid).

Does anybody have any idea of what is going on?

Thanks,

---

<div class="post-metadata">

**Author:** ![xam](https://avatars.discourse-cdn.com/v4/letter/x/bb73d2/32.png) [@xam](https://discuss.elastic.co/u/xam)\
**Post date:** [June 9, 2017, 3:53pm UTC](https://discuss.elastic.co/t/exception-using-painless-script/87223/2 "2017-06-09T15:53:25Z")

</div>

Hi,

A small "up" as I am still facing the issue.  
Do you I any idea of what I can do?  
Should I provide more information on my problem?  
Should I open an issue?

Thank you for your answer,

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [June 9, 2017, 4:24pm UTC](https://discuss.elastic.co/t/exception-using-painless-script/87223/3 "2017-06-09T16:24:06Z")

</div>

> [@xam](#):
>
> Should I provide more information on my problem?

You should always provide as much information as you can. A simple reproduction would be the most effective.

---

<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 7, 2017, 4:24pm UTC](https://discuss.elastic.co/t/exception-using-painless-script/87223/4 "2017-07-07T16:24:20Z")

</div>

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