简体   繁体   English

如何使用MarkLogic Java API调用路径范围索引查询?

[英]How to invoke a Path Range Index Query using the MarkLogic Java API?

I'm looking for an example on how to do a Path Range Index Query using the MarkLogic Java API. 我正在寻找有关如何使用MarkLogic Java API进行路径范围索引查询的示例。

/doc1.xml /doc1.xml

<a>
  <b>
    <c>1234</c>
      <d>
        <c>abcd</c>
      </d>
  </b>
</a>

/doc2.xml /doc2.xml

<a>
  <b>
    <c>abcd</c>
      <d>
        <c>abcd</c>
      </d>
  </b>
</a>

A path range index was created having this path expression with no path namespace: 创建的路径范围索引具有以下路径表达式,但没有路径名称空间:

/a/b/c

Is this the proper way to invoke a path range index query using the MarkLogic Java API? 这是使用MarkLogic Java API调用路径范围索引查询的正确方法吗?

QueryManager queryMgr = client.newQueryManager();

StructuredQueryBuilder qb = new StructuredQueryBuilder(OPTIONS_NAME);

StructuredQueryDefinition querydef = qb.PathIndex("/a/b/c", "abcd")

SearchHandle results = queryMgr.search(querydef, new SearchHandle());

You're very close. 你很亲密 Just change your second to last line to this: 只需将倒数第二行更改为此:

StructuredQueryDefinition querydef =
    qb.range(qb.pathIndex("/a/b/c"), "string", Operator.EQ, "abcd");

You don't yet need any options from anything you've described, so you could remove OPTIONS_NAME until you have a reason to specify search options. 您所描述的任何内容都不需要任何选项,因此可以删除OPTIONS_NAME,直到有理由指定搜索选项为止。 Also, make sure your path range index has the default collation or else specify the correct collation to your range method call. 另外,请确保您的路径范围索引具有默认排序规则,否则请为您的范围方法调用指定正确的排序规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM