Support multiple paths in mutation

Hi team.

I see you’ve just added support for sub-documents (KAFKAC-98), which is great news as I actually had to implement my own subdoc extension to the connector not long ago. However, my use case isn’t still fully covered with your new feature as I would like to upsert several paths at once (chained mutations on same object), so

initial document
{“name”: “foo”, “surname”: “bar”, age: 30}

when connector gets
{“name”: “werkins”, “age”: 32}

{“name”: “werkins”, “surname”: “bar”, “age”:32}

Patch code would be sth like:

JsonDocument json = convert(record);
JsonObject jsonContent = json.content();
Set<String> fieldNames = jsonContent.getNames();
SubdocOptionsBuilder subdocOptions = SubdocOptionsBuilder.builder().createPath(true);
AsyncMutateInBuilder command = bucket.async().mutateIn(documentId).upsertDocument(true);
for (String field : fieldNames) {
Object value = jsonContent.get(field);
command = command.upsert(field, value, subdocOptions);

Good idea! Would you be interested in submitting a pull request?

Sure, just created it.

1 Like