Skip to content

Instantly share code, notes, and snippets.

@peterskim12
Last active December 18, 2015 02:28
Show Gist options
  • Save peterskim12/5710840 to your computer and use it in GitHub Desktop.
Save peterskim12/5710840 to your computer and use it in GitHub Desktop.
Example of MarkLogic REST API and Play Framework XPath support
Map<String, String> namespaces = new HashMap<String, String>();
namespaces.put("search", "http://marklogic.com/appservices/search");
namespaces.put("wiki", "http://marklogic.com/wikipedia");
StructuredQueryBuilder queryBuilder = new StructuredQueryBuilder("all");
StructuredQueryDefinition queryDef = queryBuilder.term(query);
SearchHandle results = markLogicService.search(queryDef);
for (MatchDocumentSummary result : results.getMatchResults()) {
String year = XPath.selectText("/search:metadata/search:attribute-meta[@name='year' and @parent-name='nominee']", result.getMetadata(), namespaces);
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment