Currently I am trying to get data (XML) from my MarkLogic server with the Java API.
Therefore I added namespaces:
NamespacesManager nsManager = client.newServerConfigManager()
.newNamespacesManager();
nsManager.addPrefix("document",
"http://test/dummy/master/doc");
...
After that I tried following:
DatabaseClient client = DatabaseClientFactory.newClient("IP_ADDRESS",
PORT, user, password, Authentication.DIGEST);
SearchHandle handle = new SearchHandle();
QueryManager queryMgr = client.newQueryManager();
KeyValueQueryDefinition query = queryMgr.newKeyValueDefinition();
query.put(
queryMgr.newElementLocator(new QName("doc:id")),
"1439-1074");
SearchHandle resultsHandle = queryMgr.search(query, handle);
System.out.println("results: " + resultsHandle.getTotalResults());
// System.out.println("Matched "+resultsHandle.getTotalResults()+
// " documents with '"+query.getCriteria()+"'\n");
// iterate over the result documents
MatchDocumentSummary[] docSummaries = resultsHandle.getMatchResults();
System.out.println("Listing "+docSummaries.length+" documents:\n");
All works; I'm getting results but they don't contain the XML document (just URI to the document). Is it possible to get the XML result with this query or do I have to commit a second query like:
JSONDocumentManager docMgr = client.newJSONDocumentManager();
StringHandle doc = docMgr.read(uri, new StringHandle());