Updating nested field with update_by_query API

(Diego Sanchez) #1

Hello, I'm trying to update a nested field of my document through the update_by_query API, but I"m getting a casting error: [class_cast_exception] java.lang.String cannot be cast to java.util.Map

This is the body of my request;

    "script":"ctx._source.acl_policy = newAclPolicy",

Is there any fix for this?

(Chuck Peterson) #2

I just had this SAME issue exactly.
I was looking at the documentation for the wrong version and there is a slight syntax difference. Looks like you need to wrap the script and specify inline for the version if yours is similar version as mine.

curl -XPOST 'localhost:9200/scraped_links/_update_by_query' -d '{
	"script": {
		"inline":"ctx._source.scraped_data = 0"
	"query": {
		"term": {
			"scraped_data": 1

(system) #3