Unable to update subdoc in map field

java sdk 3.1.2
Couchbase server 7.0

unable to update subdoc with map
{
“managers”: {
“Food”: {
“name”: “Hash”
}
}
}
want to add address to the map with the key Food .
used mutateInSpecs.add(upsert(propName, entry.getValue()));
Mono mutationResult = reactiveCollection.mutateIn(docId, mutateInSpecs);

Caused by: com.couchbase.client.core.error.subdoc.PathNotFoundException: Subdoc path not found in the document {“completed”:true,“coreId”:“0x18d2d6a200000001”,“idempotent”:false,“index”:1,“lastChannelId”:“18D2D6A200000001/0000000021F4C910”,“lastDispatchedFrom”:“127.0.0.1:62859”,“lastDispatchedTo”:“localhost:11210”,“path”:“managers.Food.address.city”,“requestId”:11,“requestType”:“SubdocMutateRequest”,“retried”:0,“service”:{“bucket”:“travel-sample”,“collection”:“hotels”,“documentId”:“87”

expected behaviour
{
“managers”: {
“Food”: {
“name”: “Hash”,
“address”: {
“city”: “xxxx”,
}
}
}
}

Hi @selvarajc
Is propName “managers.Food.address” in your example? If so, then that should work.
If “managers” or “managers.Food” does not already exist in the document then you can use the createPath() setting to make them be created. E.g.

		collection.mutateIn(docId, Arrays.asList(
				MutateInSpec.upsert("managers.Food.address", theContent).createPath()));
1 Like

Yes Thanks had missed it