callow
callow

Reputation: 517

Inconsistency between cts:search and cts:uris in Marklogic

I have the following two docs

doc1.xml
<root>
  <parent>
    <child id="1"/>
    <child id="2" level="first"/>
  </parent>
</root>

doc2.xml
<root>
  <parent>
    <child id="2"/>
    <child id="1" level="first"/>
  </parent>
</root>

When I run:

cts:search(/root,cts:element-query(xs:QName("child"),
                                        cts:and-query((cts:element-attribute-value-query(xs:QName("child"),xs:QName("id"),"1"),
                                        cts:element-attribute-value-query(xs:QName("child"),xs:QName("level"),"first")))))

the first document is returned.

But when I run:

 cts:uris((),(),cts:element-query(xs:QName("child"),
                                        cts:and-query((cts:element-attribute-value-query(xs:QName("child"),xs:QName("id"),"1"),
                                        cts:element-attribute-value-query(xs:QName("child"),xs:QName("level"),"first")))))

uris of both documents are returned.

Please help me understand this inconsistency.

Upvotes: 1

Views: 561

Answers (1)

wst
wst

Reputation: 11771

Filtering. When you run cts:search, by default it filters out false positive results by inspecting the documents returned from the index resolution step. However, cts:uris can only run unfiltered, so it always returns all results from the index resolution step.

I suspect if you include the cts:search option to run unfiltered, your results will be the same.

cts:search(/root,
  cts:element-query(xs:QName("child"),
    cts:and-query((
      cts:element-attribute-value-query(xs:QName("child"),xs:QName("id"),"1"),
      cts:element-attribute-value-query(xs:QName("child"),xs:QName("level"),"first")))),
  'unfiltered')

For more detailed information, see MarkLogic's Query Performance and Tuning Guide.

Upvotes: 3

Related Questions