# Cannot convert MethodHandle(List,int)int to (Object,String)String

**URL:** <https://discuss.elastic.co/t/cannot-convert-methodhandle-list-int-int-to-object-string-string/134439>\
**Category:** Elasticsearch\
**Created:** [June 4, 2018, 2:28pm UTC](https://discuss.elastic.co/t/cannot-convert-methodhandle-list-int-int-to-object-string-string/134439 "2018-06-04T14:28:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![psu](https://avatars.discourse-cdn.com/v4/letter/p/cc9497/32.png) [@psu](https://discuss.elastic.co/u/psu)\
**Post date:** [June 4, 2018, 2:28pm UTC](https://discuss.elastic.co/t/cannot-convert-methodhandle-list-int-int-to-object-string-string/134439/1 "2018-06-04T14:28:50Z")

</div>

I'm using \_update\_by\_query with script which contains many if's like this:

```
ArrayList tmp=[];
if(ctx._source.anketa["REGION"]==3){tmp.add(2);}
if(ctx._source.anketa["REGION"]==4){tmp.add(5);}
if(ctx._source.anketa["REGION"]==5){tmp.add(3);}
 if(ctx._source.anketa["REGION"]==6){tmp.add(7);}
...
ctx._source.anketa["anotherfield"] = tmp;

```

At some point I get exception:  
array (  
'type' =\> 'wrong\_method\_type\_exception',  
'reason' =\> 'cannot convert MethodHandle(List,int)int to (Object,String)String',  
),  
'script\_stack' =\>  
array (  
0 =\> 'if(ctx.\_source.anketa["REGION"]==1){',  
1 =\> '.......................^---- HERE',  
),

How can I debug which document causes this? I need some instanceof verification I think, but I have very little Java knowledge.

---

<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 2, 2018, 2:29pm UTC](https://discuss.elastic.co/t/cannot-convert-methodhandle-list-int-int-to-object-string-string/134439/2 "2018-07-02T14:29:05Z")

</div>

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