Hello.
Elasticsearch 5.4.2. I have the following index mapping:
{
"pop": {
"mappings": {
"poptype": {
"properties": {
"popnested": {
"type": "nested",
"properties": {
"first": {
"type": "keyword",
"fields": {
"_lowercase": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
}
}
},
"second": {
"type": "keyword",
"fields": {
"_lowercase": {
"type": "keyword",
"normalizer": "lowercase_normalizer"
}
}
}
}
}
}
}
}
}
}
I need to delete field from index, so I am trying to reindex my 'pop' index into new one without 'popnested.second' field. My code works fine only if 'popnested.second' does not contain any data but when it is not empty, I have the following exception:
ReindexAction.INSTANCE.newRequestBuilder( transportClient )
.source( pop )
.destination( newPop )
.script( new Script( "if (ctx._type==\"poptype"\) { if(ctx._source.popnested!==null )" +
" {ctx._source.popnested.remove(\"second\"); } } " ) ).execute().get();
RemoteTransportException[[elastic-my-node][127.0.0.1][indices:data/write/reindex]]; nested: ScriptException[runtime error]; nested: NotSerializableExceptionWrapper[wrong_method_type_exception: cannot convert MethodHandle(List,int)Object to (Object,String)Object];
Could you explain me where is my mistake? please.