Hi there,

I have this document in Marklogic:

{

"resource":

{

"name": "hrRFIrq2JzpiXmc",

"url": "k4llhWiubj2SHtl",

"importer": "UXwZbxVCOfNFeST",

"text_context": "qerXqhThyAtdQkNhXZ2FMZwY5JIX4quQTwQwHflsw3hl2RZNYu",

"title": "QBV877tmh5Y18Z2",

"subject": "8NPCWTGUF5k5iYB",

"author": "xnONnboaNlaL7q5",

"author_role": "tu8kTbQn0yWNMX1",

"author_organisation": "x36qaVbgIXuHgCw",

"tags":

[

{

"tag": "AoFCPDLY33A4fww",

"class": "L52uePB2HcklJu2"

}

,

{

"tag": "7ByYULGv36DhTSa",

"class": "NUjndXpM2y8wQ2g"

}

,

{

"tag": "4MRydSIXDBHcqaE",

"class": "v17DV2Xgkjh6AZq"

}

,

{

"tag": "2nFrUOh0lKGwVUJ",

"class": "NmSIjx2nqd7SIp4"

}

],

"comments": "GtdMrgackvjcP2s",

"date_created": 808426552630988,

"date_modified": 44633806482503

}

}

And I'm trying to add more objects to the Tags Array.

I've tried this:

ObjectNode fragmentNode = mapper.createObjectNode();
fragmentNode.put("tag", "blahblah");
fragmentNode.put("class", "the class");
String fragment = mapper.writeValueAsString(fragmentNode);
documentPatchBuilder.insertFragment("/resource/tags",
DocumentPatchBuilder.Position.LAST_CHILD, fragment);


And also this:

ObjectNode fragmentNode = mapper.createObjectNode();
fragmentNode.put("tag", "blahblah");
fragmentNode.put("class", "the class");
String fragment = mapper.writeValueAsString(fragmentNode);

documentPatchBuilder.replaceInsertFragment("/documents/thefile.json",
"/resource/tags", DocumentPatchBuilder.Position.LAST_CHILD, fragment);


But I keep getting this error message : Object nodes cannot have two
children with the same name.

Now nodes that I'm inserting (insertFragment) works, only this "adding to
existing" doesn't.

Anyone can point me in the right direction?

Thanks.

Desmond
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to