Error when try to use newest strutures (List, Set, Map, Queue)

When I try to use a special structure I had some issues:

When the key does not exist and I use append list:

bucket.listAppend("mykey", object);

Then it returns an exception Document not found for subdoc API: mykey

When I created the key before:


And then do the append on the list

bucket.listAppend("mykey", object);

It returns a NPE:

cause: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: java.util.ArrayList.class

This same error happened also on Set, Map and Queue. Also when I try to use just either String or a complex object.

My version:


My server version:
Version: 4.5.1-2844 Enterprise Edition (build-2844)

Hi @otaviopolianasantana,

The underlying document is different for each data structure, list uses JsonArrayDocument. It is more straightforward to create the document using datastructures api
ctx.bucket().listAppend(“mykey”, “”, MutationOptionBuilder.builder().createDocument(true));

I couldn’t reproduce the exact error, you are seeing but,

bucket.listAppend(“mykey”, “foo”);

throws DocumentNotJsonException which is valid because the first line creates a document which is null.

bucket.insert(JsonDocument.create("mykey", JsonObject.create())); bucket.listAppend("mykey", "foo"); will throw SUBDOC_PATH_MISMATCH as it tries append to {} instead of an array bucket.insert(JsonArrayDocument.create("mykey", JsonArray.create()); bucket.listAppend("mykey", "foo"); This should work

Thanks, that works on List.
Do you know where on documentation has this information?
Or can you give the document type to the others structures (Set, Map, Queue)?


That information is not exposed on the bucket-level datastructure operations, collections api would expose those

Using MutationOptionBuilder createDocument takes care of it when using bucket operations.

bucket.listAppend(“mykey”, “”, MutationOptionBuilder.builder().createDocument(true))

Thanks that’s working :slight_smile:

1 Like