0

I am trying to understand the usage of

cts:element-values($element-names as xs:QName*,[$start as xs:anyAtomicType?])

I was under the impression that the above function returns values from the specified element value lexicon, starting with $start. On Querying:

cts:element-values(xs:QName("ts:title"), "He")

I was expecting results starting with "He" only, but I have also got results such as:

(as I scroll down) I Feel Fine

I Get Around

I would like to know what exactly does $start specify ?

Yash
  • 510
  • 2
  • 6
  • 14
  • can you confirm that you have values staring with 'H' and 'He'? – Tamas Jul 21 '17 at 10:48
  • Hi Tamas, I have got values starting with "He" and "H" in my results. I am confused why am I getting additional values such as "I Feel Fine" in my results. – Yash Jul 21 '17 at 10:54
  • I believe that this function returns the values starting from your start position and then continues on until it the end. – Tamas Jul 21 '17 at 10:56

2 Answers2

4

Think of $start not as a starting prefix but as a starting location in the list. You're getting all the values from that point onward.

To limit by prefix you want to use cts:element-value-match which accepts a $pattern. http://docs.marklogic.com/cts:element-value-match

hunterhacker
  • 6,378
  • 1
  • 14
  • 11
  • just out of curiosity how can I pattern match double type range indices? cts:element-value-match(xs:QName("rating"), 7); (: where rating has values like 7.1, 7.2 etc :) – Tamas Jul 21 '17 at 11:25
  • Assuming a single value per fragment, you could add a `cts:element-range-query` as the query constraint. You're right though, the API for `cts:element-value-match` allows any atomic type but I've never tried it with floats. – hunterhacker Jul 23 '17 at 07:48
1

cts:element-values and the like return values greater or equal to $start value. It really is just a start place for all values, until limit is depleted.

If you are looking for a function that returns values matching a particular pattern, you probably want to use cts:element-value-match instead:

cts:element-value-match(xs:QName("title"), "He*")

HTH!

grtjn
  • 20,254
  • 1
  • 24
  • 35