Loading TOC...

sql:bucket

sql:bucket(
   bucketEdgesParam as xs:anyAtomicType*,
   srchParam as xs:anyAtomicType,
   [collationLiteral as xs:string]
) as xs:integer*

Summary

Returns an unsignedLong specifying the index of the bucket the second parameter belongs to in buckets formed by the first parameter. Values that lie on the edge of a bucket fall to the greater index.

Parameters
bucketEdgesParam A sequence of ordered values indicating the edges of a collection of buckets. If the sequence is out of order or has duplicates, SQL-UNORDERED is thrown.
srchParam A value to find an index for in the bucket edge list.
collationLiteral A collation identifier. All bucketEdgesParam and srcParam are converted to a string of this collation if supplied.

Example

for $i in (1,5,10)
  return sql:bucket((2,4,6,7,8), $i)
=>
0
2
5

Example

sql:bucket(('Aขเ','Aเ', 'B'), 'Aเข', 'http://marklogic.com/collation/th')
=>
0

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.