*I have read the nested docs and create mapping and get mapping as follow* "fields": { "type": "nested", "properties": { "_id": { "type": "string" }, "name": { "type": "string" } } }
*where fields is my array contain the following* "fields": [ { "_id": "1", "name": "naveen" }, { "_id": "2", "name": "rajit" }, { "_id": "3", "name": "ashu" } ] *I want to update and remove object from this array, and I am doing this,* client.update({"index": "daffosw","type": "daffo","id": "2501","body": { "script" : "for (int i = 0; i < ctx._source.fields.size(); i++){ if(ctx._source.fields[i]_id == id){ ctx._source.fields[i].name = 'Updated John'; } }", "params" : { "id" : "1" } }} *and I am getting this error* VerifyError[Bad type on operand stack Exception Details: Location: ASMAccessorImpl_18539991071412750271920.getValue(Ljava/lang/Object;Ljava/lang/Object;Lorg/elasticsearch/common/mvel2/integration/VariableResolverFactory;)Ljava/lang/Object; @49: invokeinterface Reason: Type 'java/lang/Object' (current frame, stack[1]) is not assignable to integer Current Frame: bci: @49 flags: { } locals: { 'ASMAccessorImpl_18539991071412750271920', 'java/lang/Object', 'java/lang/Object', 'org/elasticsearch/common/mvel2/integration/VariableResolverFactory' } stack: { 'java/util/List', 'java/lang/Object' }............ ............................................................. ......................................................... *then I have tried this* client.update({"index": "daffosw","type": "daffo","id": "2501","body": { "script" : "for (int i = 0; i < ctx._source.fields.size(); i++){ if(ctx._source.fields[i]_id == id){ ctx._source.fields.remove(i); } }", "params" : { "id" : "1" } }} *and this is giving the same type of error* *then I have tried* client.update({"index": "daffosw","type": "daffo","id": "2501","body": { "script" : "for (element : doc['fields'].values){ if(element._id == id){ element.name = 'Updated John'; } }", "params" : { "id" : "1" } }} *which gives this error* *elasticsearchIllegalArgumentException[failed to execute script]; nested: PropertyAccessException[[Error: unresolvable property or identifier: doc]* please help.... -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/1c65f529-6e6b-4415-8f93-662acbac9929%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.