If I have to insert a document in MarkLogic, how can I specify in which forest the document should be stored, using the Java API?
Here is an example where I write data to a MarkLogic database :
// create the client
DatabaseClient client = DatabaseClientFactory.newClient(
props.host, props.port, props.writerUser, props.writerPassword,
props.authType);
// make use of the client connection
TextDocumentManager docMgr = client.newTextDocumentManager();
String docId = "/example/text.txt";
StringHandle handle = new StringHandle();
handle.set("A simple text document");
docMgr.write(docId, handle);
If I can store the document by specifying the forest, then I also need to fetch the document with the forest specified.
I think it is possible because I have seen storing and searching within a specific forestId in XQuery. Like so:
insert into a specific forest:
xdmp:document-insert(
$uri as xs:string,$root as node(),
[$permissions as element(sec:permission)*], [$collections as xs:string*],
[$quality as xs:int?], [$forest-ids as xs:unsignedLong*])
as empty-sequence()
search a specific to forest -
cts:search(
$expression as node()*, $query as cts:query?,
[$options as (cts:order|xs:string)*], [$quality-weight as xs:double?],
[$forest-ids as xs:unsignedLong*]) as node()*
Please let me know how to do this in the Java API.