cts:element-attribute-range-query( $element-name as xs:QName*, $attribute-name as xs:QName*, $operator as xs:string, $value as xs:anyAtomicType*, [$options as xs:string*], [$weight as xs:double?] ) as cts:element-attribute-range-query
cts:query matching element-attributes by name with a
range-index entry equal to a given value. Searches with the
constructor require an attribute range index on the specified QName(s);
if there is no range index configured, then an exception is thrown.
|$element-name||One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches.|
|$attribute-name||One or more attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches.|
A comparison operator.
|$value||Some values to match. When multiple values are specified, the query matches if any value matches.|
Options to this query. The default is ().
|$weight||A weight for this query. The default is 1.0.|
If you want to constrain on a range of values, you can combine multiple
cts:element-attribute-range-query constructors together
cts:and-query or other composable
If neither "cached" nor "uncached" is present, it specifies "cached".
Negative "min-occurs" or "max-occurs" values will be treated as 0 and non-integral values will be rounded down. An error will be raised if the "min-occurs" value is greater than the "max-occurs" value.
"score-function=linear" means that values that are further away from the bounds will score higher. "score-function=reciprocal" means that values that are closer to the bounds will score higher. The functions are scaled appropriately for different types, so that in general the default slope factor will provide useful results. Using a slope factor greater than 1 gives distinct scores over a smaller range of values, and produces generally higher scores. Using a slope factor less than 1 gives distinct scores over a wider range of values, and produces generally lower scores.
(: create a document with test data :) xdmp:document-insert("/attributes.xml", <root> <entry sku="100"> <product>apple</product> </entry> <entry sku="200"> <product>orange</product> </entry> <entry sku="1000"> <product>electric car</product> </entry> </root>) ; (: requires an attribute (range) index of type xs:int on the "sku" attribute of the "entry" element :) cts:search(doc("/attributes.xml")/root/entry, cts:element-attribute-range-query( xs:QName("entry"), xs:QName("sku"), ">=", 500)) (: returns the following node: <entry sku="1000"> <product>electric car</product> </entry> :)