目前我正試圖從我的MarkLogic服務器獲取數據(XML)和Java API。MarkLogic Java API - 如何獲取文檔
所以我加了命名空間:
NamespacesManager nsManager = client.newServerConfigManager()
.newNamespacesManager();
nsManager.addPrefix("document",
"http://test/dummy/master/doc");
...
之後,我嘗試以下操作:
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");
所有的作品;我正在獲取結果,但它們不包含XML文檔(只是文檔的URI)。是否有可能得到與此查詢XML結果還是我犯像第二個查詢:
JSONDocumentManager docMgr = client.newJSONDocumentManager();
StringHandle doc = docMgr.read(uri, new StringHandle());
感謝您的迴應,但只是更改結果句柄不解決我的問題。結果是一樣的(數據只包含uris)。 – user1731299