I tried the following command and that didn’t work either
MapOperation.put(mapPolicy, “map”, Value.get(“count”), Value.get(10), CTX.mapKey(Value.get(“123”))))
and I get the following error : com.aerospike.client.AerospikeException: Error 26,1,30000,5000,1,BB9979897BC230A 172.17.35.56 3000: Operation not applicable
Yes, but it will depend on the version of the Java client and Aerospike server that you are running.
The MapOperation.increment in the current Java version (5.0.2) supports passing a context to find the element to apply the operation to.
Aerospike 4.6.0.2 introduced support for nested List/Map update operations via context parameter.
Aerospike 4.9.0.3 introduced support for nested List/Map operations via context parameter that can create the elements in the context path (similar to mkdir -p).
If I use increment instead of put, do both keys still need to exist?
For regular maps if key doesn’t exist MapOperation.increment creates the key. Should it work the same way for nested maps?
You have to specify a context flag for that to happen. That has been implemented since 4.9.0.3. I’m not sure how to do that in Java but the context flag to create context (if it didn’t exist) should be there.