Elasticsearch Update API in Java for HashMap is not working

Hi,
I have created an index in elastic search where it has data something like this,

{
	"teamPermission":{
		"1":2,
		"2":2,
		"3":2
	},
	"userPermission":{
		"18":"1"
	},
	"unique":"N",
	"name":"ABC",
	"code":"abc",
	"values":{
		"Yes":"Yes",
		"No":"No"
	},
	"lastModifiedBy":18
}

I'm updating the index through Java API using update.
If anything gets changed in data, for example, any value gets added for the team permission field,
the index will have the same data as expected but, if I delete any value from the field team permission for example, If I remove "1": 2 value then it should be

"teamPermission":{
		"2":2,
		"3":2
	}

but it is not reflecting in the index. It's same as previous for each delete operation from HashMap.
I have given mappings as an object for the field.

Can anyone please tell me why data is not deleting from Map?

Thanks in advance!

Hi @supritha,

I believe you are using the merge docs functionality of the update API, described in more detail here: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-update.html#java-docs-update-api-merge-docs

Pay attention to: "simple recursive merge, inner merging of objects", meaning that all data are merged at all levels, effectively never deleting any data.

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