Marklogic java api 查询记录器

Marklogic java api query logger

我想 运行 下面的查询来获取 JSON 的特定部分:

cts:search(/user/userdetail, cts:word-query("test1"))

在 java 中使用 Marklogic Java API。

上面的查询给了我完美的结果,但我想使用 Marklogic java 客户端在 java 中编写代码。

下面是 json 文件:

{
  "user": {
    "userdetail": [
      {
        "username": "test",
        "firstName": "testName",
        "lastName": "testLastName",
        "maritalStatus": "Unmarried",
        "password": "testPassword"
      },
      {
        "username": "test1",
        "firstName": "testName1",
        "lastName": "testLastName2",
        "maritalStatus": "married",
        "password": "testPassword1"
      }
    ]
  }
}
QueryManager queryMgr = databaseClient.newQueryManager();
RawCombinedQueryDefinition query = queryMgr.newRawCombinedQueryDefinitionAs(Format.JSON,
  "{\"search\": {" +
  "  \"qtext\": \"test1\"," +
  "  \"options\": {" +
  "    \"searchable-expression\": {" +
  "      \"text\": \"/user/userdetail\"" +
  "    }," +
  "    \"transform-results\": {\"apply\": \"raw\"}" +
  "}}}"
);
JsonNode jsonResponse = queryMgr.search(query, new JacksonHandle()).get();
JsonNode firstMatch = jsonResponse.path("results").path(0).path("content");