2

I'm looking for an example on how to do a Path Range Index Query using the MarkLogic Java API.

/doc1.xml

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

/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?

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());

1 Answer 1

3

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. Also, make sure your path range index has the default collation or else specify the correct collation to your range method call.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.