I can't understand deference between cts:search
and cts:element-attribute-values
.
I can get the same result with both these functions.
What is the best resolve?
cts:search(/t:ancestors-list/t:concept/t:concept-ancestor, cts:element-value-query(xs:QName("t:concept-ancestor"), $concept/id))/@subject
or
cts:element-attribute-values(
xs:QName("t:concept-ancestor"),
xs:QName("subject"),
(),
("collation=http://marklogic.com/collation/codepoint"),
cts:element-value-query(
xs:QName("t:concept-ancestor"),
$concept/id
)
)
ar:concept-ancestor is the element range index and element attribute range index.
And xml structure like this
<t:ancestors-list xmlns:ar="http://test.com">
<t:concept subject="http://test.com/concept#1c5cd7082ac908c62e9176770ae0fb53">
<t:concept-ancestor subject="http://test.com/concept#1c5cd7082ac908c62e9176770ae0fb53">4a1f650290103d39863bf7bc22ef18aa</t:concept-ancestor>
</t:concept>
<t:concept subject="http://test.com/concept#05b707457f79f42c93bf778915e4a589">
<t:concept-ancestor subject="http://test.com/concept#05b707457f79f42c93bf778915e4a589">4a1f650290103d39863bf7bc22ef18aa</t:concept-ancestor>
<t:concept-ancestor subject="http://test.com/concept#05b707457f79f42c93bf778915e4a589">1c5cd7082ac908c62e9176770ae0fb53</t:concept-ancestor>
</t:concept>
...
</t:ancestors-list>
Thank you!
cts:element-attribute-values
requires an element-attribute range index be configured on the values you're querying, and it only returns an atomic type (xs:anyAtomicType*
).cts:search
returns document nodes, and no indexes are required forcts:element-value-query
.If you only need the values (not XML) and you already have an index, then the
cts:element-attribute-values
query will be faster.