This page was generated
July 7, 2010
4:03 PM
XQuery Built-In and Modules Function Reference

Built-In: Search

The geospatial built-in functions are XQuery functions defined to operate on geospatial values.

The search built-in functions are XQuery functions used to perform text searches. The search functions are designed for use with XML structured text. Searches that use these functions use the indexes and are designed to return fast.

There are built-in functions to search through documents (cts:search, cts:contains and cts:highlight); there is a function to tokenize text into different types (cts:tokenize), and there are functions to retrieve result characteristics (for example cts:quality and cts:score). There are also built-in functions to browse word and value lexicons (cts:words, cts:element-values, and so on.) The lexicon built-in functions require the appropriate lexicons to be enabled in the Admin interface.

There are also functions to compose a cts:query, as well as accessor functions to retrieve the parameter values from a cts:query. These functions are documented in the cts:query Constructors section.

Function Summary
cts:and-not-query Returns a query specifying the set difference of the matches specified by two sub-queries.
    cts:and-not-query-negative-query
Returns the negative (second parameter) query used to construct the specified query.
    cts:and-not-query-positive-query
Returns the positive (first parameter) query used to construct the specified query.
cts:and-query Returns a query specifying the intersection of the matches specified by the sub-queries.
    cts:and-query-options
Returns the options for the specified query.
    cts:and-query-queries
Returns a sequence of the queries that were used to construct the specified query.
cts:box Returns a geospatial box value.
cts:box-east Returns a box's eastern boundary.
cts:box-north Returns a box's northern boundary.
cts:box-south Returns a box's southern boundary.
cts:box-west Returns a box's western boundary.
cts:circle Returns a geospatial circle value.
cts:circle-center Returns a circle's center point.
cts:circle-radius Returns a circle's radius.
cts:collection-match Returns values from the collection lexicon that match the specified wildcard pattern.
cts:collection-query Returns a query matching documents in the collections with the given URIs.
    cts:collection-query-uris
Returns the URIs used to construct the specified query.
cts:collections Returns values from the collection lexicon.
cts:confidence Returns the confidence of a node, or of the context node if no node is provided.
cts:contains Returns true if any of a sequence of nodes matches a query.
cts:deregister Deregister a registered query, explicitly releasing the associated resources.
cts:directory-query Returns a query matching documents in the directories with the given URIs.
    cts:directory-query-depth
Returns the depth used to construct the specified query.
    cts:directory-query-uris
Returns the URIs used to construct the specified query.
cts:distance Returns the distance (in miles) between two points.
cts:document-query Returns a query matching documents with the given URIs.
    cts:document-query-uris
Returns the URIs used to construct the specified query.
cts:element-attribute-pair-geospatial-boxes Returns boxes derived from the specified element point lexicon(s).
cts:element-attribute-pair-geospatial-query Returns a cts:query matching elements by name which has specific attributes representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point.
    cts:element-attribute-pair-geospatial-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-attribute-pair-geospatial-query-latitude-name
Returns the QNames used to construct the specified query.
    cts:element-attribute-pair-geospatial-query-longitude-name
Returns the QNames used to construct the specified query.
    cts:element-attribute-pair-geospatial-query-options
Returns the options for the specified query.
    cts:element-attribute-pair-geospatial-query-region
Returns the geographical regions with which the specified query was constructed.
    cts:element-attribute-pair-geospatial-query-weight
Returns the weight with which the specified query was constructed.
cts:element-attribute-pair-geospatial-value-match Returns values from the specified element attribute pair geospatial value lexicon(s) that match the specified wildcard pattern.
cts:element-attribute-pair-geospatial-values Returns values from the specified element-attribute-pair geospatial value lexicon(s).
cts:element-attribute-range-query Returns a cts:query matching elements by name with a range-index entry equal a given value.
    cts:element-attribute-range-query-attribute-name
Returns the QNames used to construct the specified query.
    cts:element-attribute-range-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-attribute-range-query-operator
Returns the operator used to construct the specified query.
    cts:element-attribute-range-query-options
Returns the options for the specified query.
    cts:element-attribute-range-query-value
Returns the value used to construct the specified query.
    cts:element-attribute-range-query-weight
Returns the weight with which the specified query was constructed.
cts:element-attribute-value-co-occurrences Returns value co-occurrences from the specified element or element-attribute value lexicon(s).
cts:element-attribute-value-geospatial-co-occurrences Returns value co-occurrences from the specified element-attribute value lexicon with the specified geospatial lexicon.
cts:element-attribute-value-match Returns values from the specified element-attribute value lexicon(s) that match the specified pattern.
cts:element-attribute-value-query Returns a query matching elements by name with attributes by name with text content equal a given phrase.
    cts:element-attribute-value-query-attribute-name
Returns the attribute QNames used to construct the specified query.
    cts:element-attribute-value-query-element-name
Returns the element QNames used to construct the specified query.
    cts:element-attribute-value-query-options
Returns the options for the specified query.
    cts:element-attribute-value-query-text
Returns the text used to construct the specified query.
    cts:element-attribute-value-query-weight
Returns the weight with which the specified query was constructed.
cts:element-attribute-value-ranges Returns value ranges from the specified element-attribute value lexicon(s).
cts:element-attribute-values Returns values from the specified element-attribute value lexicon(s).
cts:element-attribute-word-match Returns words from the specified element-attribute word lexicon(s) that match a wildcard pattern.
cts:element-attribute-word-query Returns a query matching elements by name with attributes by name with text content containing a given phrase.
    cts:element-attribute-word-query-attribute-name
Returns the attribute QNames used to construct the specified query.
    cts:element-attribute-word-query-element-name
Returns the element QNames used to construct the specified query.
    cts:element-attribute-word-query-options
Returns the options for the specified query.
    cts:element-attribute-word-query-text
Returns the text used to construct the specified query.
    cts:element-attribute-word-query-weight
Returns the weight with which the specified query was constructed.
cts:element-attribute-words Returns words from the specified element-attribute word lexicon(s).
cts:element-child-geospatial-boxes Returns boxes derived from the specified element point lexicon(s).
cts:element-child-geospatial-query Returns a cts:query matching elements by name which has specific element children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point.
    cts:element-child-geospatial-query-child-name
Returns the QNames used to construct the specified query.
    cts:element-child-geospatial-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-child-geospatial-query-options
Returns the options for the specified query.
    cts:element-child-geospatial-query-region
Returns the geographical regions with which the specified query was constructed.
    cts:element-child-geospatial-query-weight
Returns the weight with which the specified query was constructed.
cts:element-child-geospatial-value-match Returns values from the specified element child geospatial value lexicon(s) that match the specified wildcard pattern.
cts:element-child-geospatial-values Returns values from the specified element-child geospatial value lexicon(s).
cts:element-geospatial-boxes Returns boxes derived from the specified element point lexicon(s).
cts:element-geospatial-query Returns a cts:query matching elements by name whose content represents a point contained within the given geographic box, circle, or polygon, or equal to the given point.
    cts:element-geospatial-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-geospatial-query-options
Returns the options for the specified query.
    cts:element-geospatial-query-region
Returns the geographical regions with which the specified query was constructed.
    cts:element-geospatial-query-weight
Returns the weight with which the specified query was constructed.
cts:element-geospatial-value-match Returns values from the specified element geospatial value lexicon(s) that match the specified wildcard pattern.
cts:element-geospatial-values Returns values from the specified element geospatial value lexicon(s).
cts:element-pair-geospatial-boxes Returns boxes derived from the specified element point lexicon(s).
cts:element-pair-geospatial-query Returns a cts:query matching elements by name which has specific element children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point.
    cts:element-pair-geospatial-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-pair-geospatial-query-latitude-name
Returns the QNames used to construct the specified query.
    cts:element-pair-geospatial-query-longitude-name
Returns the QNames used to construct the specified query.
    cts:element-pair-geospatial-query-options
Returns the options for the specified query.
    cts:element-pair-geospatial-query-region
Returns the geographical regions with which the specified query was constructed.
    cts:element-pair-geospatial-query-weight
Returns the weight with which the specified query was constructed.
cts:element-pair-geospatial-value-match Returns values from the specified element pair geospatial value lexicon(s) that match the specified wildcard pattern.
cts:element-pair-geospatial-values Returns values from the specified element-pair geospatial value lexicon(s).
cts:element-query Returns a cts:query matching elements by name with the content constrained by the given cts:query in the second parameter.
    cts:element-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-query-query
Returns the query used to construct the element query.
cts:element-range-query Returns a cts:query matching elements by name with a range-index entry equal a given value.
    cts:element-range-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-range-query-operator
Returns the operator used to construct the specified query.
    cts:element-range-query-options
Returns the options for the specified query.
    cts:element-range-query-value
Returns the value used to construct the specified query.
    cts:element-range-query-weight
Returns the weight with which the specified query was constructed.
cts:element-value-co-occurrences Returns value co-occurrences (that is, pairs of values, both of which appear in the same fragment) from the specified element value lexicon(s).
cts:element-value-geospatial-co-occurrences Returns value co-occurrences from the specified element value lexicon with the specified geospatial lexicon.
cts:element-value-match Returns values from the specified element value lexicon(s) that match the specified wildcard pattern.
cts:element-value-query Returns a query matching elements by name with text content equal a given phrase.
    cts:element-value-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-value-query-options
Returns the options for the specified query.
    cts:element-value-query-text
Returns the text used to construct the specified query.
    cts:element-value-query-weight
Returns the weight with which the specified query was constructed.
cts:element-value-ranges Returns value ranges from the specified element value lexicon(s).
cts:element-values Returns values from the specified element value lexicon(s).
cts:element-word-match Returns words from the specified element word lexicon(s) that match a wildcard pattern.
cts:element-word-query Returns a query matching elements by name with text content containing a given phrase.
    cts:element-word-query-element-name
Returns the QNames used to construct the specified query.
    cts:element-word-query-options
Returns the options for the specified query.
    cts:element-word-query-text
Returns the text used to construct the specified query.
    cts:element-word-query-weight
Returns the weight with which the specified query was constructed.
cts:element-words Returns words from the specified element word lexicon.
cts:entity-highlight Returns a copy of the node, replacing any entities found with the specified expression.
cts:field-word-match Returns words from the specified field word lexicon(s) that match a wildcard pattern.
cts:field-word-query Returns a query matching text content containing a given phrase in the specified field.
    cts:field-word-query-field-name
Returns the names used to construct the specified cts:field-word-query.
    cts:field-word-query-options
Returns the options for the specified cts:field-word-query.
    cts:field-word-query-text
Returns the text used to construct the specified cts:field-word-query.
    cts:field-word-query-weight
Returns the weight with which the specified query was constructed.
cts:field-words Returns words from the specified field word lexicon.
cts:fitness Returns the fitness of a node, or of the context node if no node is provided.
cts:frequency Returns an integer representing the number of times in which a particular value occurs in a value lexicon lookup (for example, cts:element-values).
cts:geospatial-co-occurrences Returns value co-occurrences from the geospatial lexicons.
cts:highlight Returns a copy of the node, replacing any text matching the query with the specified expression.
cts:near-query Returns a query matching all of the specified queries, where the matches occur within the specified distance from each other.
    cts:near-query-distance
Returns the distance used to construct the near query.
    cts:near-query-options
Returns the options for the specified query.
    cts:near-query-queries
Returns the query sequence used to construct the near query.
    cts:near-query-weight
Returns the weight with which the specified query was constructed.
cts:not-query Returns a query specifying the matches not specified by its sub-query.
    cts:not-query-query
Returns the query used to construct the specified query.
    cts:not-query-weight
Returns the weight with which the specified query was constructed.
cts:or-query Returns a query specifying the union of the matches specified by the sub-queries.
    cts:or-query-queries
Returns a sequence of the queries that were used to construct the specified query.
cts:point Returns a point value.
cts:point-latitude Returns a point's latitude value.
cts:point-longitude Returns a point's longitude value.
cts:polygon Returns a geospatial polygon value.
cts:polygon-vertices Returns a polygon's vertices.
cts:quality Returns the quality of a node, or of the context node if no node is provided.
cts:query Creates a query.
cts:register Register a query for later use.
cts:registered-query Returns a query matching fragments specified by previously registered queries (see cts:register).
    cts:registered-query-ids
Returns the registered query identifiers used to construct the specified query.
    cts:registered-query-options
Returns the options for the specified query.
    cts:registered-query-weight
Returns the weight with which the specified query was constructed.
cts:remainder Returns an estimated search result size for a node, or of the context node if no node is provided.
cts:reverse-query Returns a query matching the model nodes.
    cts:reverse-query-nodes
Returns the nodes used to construct the specified query.
    cts:reverse-query-weight
Returns the weight with which the specified query was constructed.
cts:score Returns the score of a node, or of the context node if no node is provided.
cts:search Returns a relevance-ordered sequence of nodes specified by a given query.
cts:similar-query Returns a query matching nodes similar to the model nodes.
    cts:similar-query-nodes
Returns the nodes used to construct the specified query.
    cts:similar-query-weight
Returns the weight with which the specified query was constructed.
cts:stem Returns the stem(s) for a word.
cts:tokenize Tokenizes text into words, punctuation, and spaces.
cts:uri-match Returns values from the URI lexicon that match the specified wildcard pattern.
cts:uris Returns values from the URI lexicon.
cts:word-match Returns words from the word lexicon that match the wildcard pattern.
cts:word-query Returns a query matching text content containing a given phrase.
    cts:word-query-options
Returns the options for the specified query.
    cts:word-query-text
Returns the text used to construct the specified query.
    cts:word-query-weight
Returns the weight with which the specified query was constructed.
cts:words Returns words from the word lexicon.
Function Detail
cts:and-not-query(
$positive-query as cts:query,
$negative-query as cts:query
)  as  cts:and-not-query
Summary:

Returns a query specifying the set difference of the matches specified by two sub-queries.

Parameters:
$positive-query : A positive query, specifying the search results filtered in.
$negative-query : A negative query, specifying the search results to filter out.

Usage Notes:

The cts:and-not-query constructor is fragment-based, so it returns true only if the specified query does not produce a match anywhere in a fragment. Therefore, a search using cts:and-not-query is only guaranteed to be accurate if the underlying query that is being negated is accurate from its index resolution (that is, if the unfiltered results of the $negative-query parameter to cts:not-query are accurate). The accuracy of the index resolution depends on many factors such as the query, if you search at a fragment root (that is, if the first parameter of cts:search specifies an XPath that resolves to a fragment root), the index options enabled on the database, the search options, and other factors. In cases where the $negative-query parameter has false positive matches, the negation of the query can miss matches (have false negative matches). In these cases, searches with cts:and-not-query can miss results, even if those searches are filtered.

Example:
  cts:search(//PLAY,
    cts:and-not-query(
      cts:word-query("summer"),
      cts:word-query("glorious")))
  => .. sequence of 'PLAY' elements containing some
  text node with the word 'summer' BUT NOT containing
  any text node with the word 'glorious'.  This sequence
  may be (in fact is) non-empty, but certainly does not
  contain the PLAY element with:

    PLAY/TITLE = 
      "The Tragedy of King Richard the Second"

  since this play contains both 'glorious' and 'summer'.

cts:and-not-query-negative-query(
$query as cts:and-not-query
)  as  cts:query
Summary:

Returns the negative (second parameter) query used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:and-not-query(
                 cts:word-query("wanted"), 
                 cts:word-query("unwanted"))
return cts:and-not-query-negative-query($query)
  
  => cts:word-query("unwanted", (), 1)

cts:and-not-query-positive-query(
$query as cts:and-not-query
)  as  cts:query
Summary:

Returns the positive (first parameter) query used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:and-not-query(
                 cts:word-query("wanted"), 
                 cts:word-query("unwanted"))
return cts:and-not-query-positive-query($query)
  
  => cts:word-query("wanted", (), 1)

cts:and-query(
$queries as cts:query*,
[$options as xs:string*]
)  as  cts:and-query
Summary:

Returns a query specifying the intersection of the matches specified by the sub-queries.

Parameters:
$queries : A sequence of sub-queries.
$options (optional): Options to this query. The default is ().

Options include:

"ordered"
An ordered and-query, which specifies that the sub-query matches must occur in the order of the specified sub-queries. For example, if the sub-queries are "cat" and "dog", an ordered query will only match fragments where both "cat" and "dog" occur, and where "cat" comes before "dog" in the fragment.
"unordered"
An unordered and-query, which specifies that the sub-query matches can occur in any order.

Usage Notes:

If the options parameter contains neither "ordered" nor "unordered", then the default is "unordered".

If you specify the empty sequence for the queries parameter to cts:and-query, you will get a match for every document in the database. For example, the following query always returns true:

   cts:contains(collection(), cts:and-query(()))

In order to match a cts:and-query, the matches from each of the specified sub-queries must all occur in the same fragment.


Example:
  cts:search(//PLAY,
    cts:and-query((
      cts:word-query("to be or"),
      cts:word-query("or not to be"))))
  => .. a sequence of 'PLAY' elements which are
  ancestors (or self) of some node whose text content
  contains the phrase 'to be or' AND some node
  whose text content contains the phrase 'or not to be'.
  With high probability this intersection contains only 
  one 'PLAY' element, namely,
    
    PLAY/TITLE = 
      "The Tragedy of Hamlet, Prince of Denmark".

cts:and-query-options(
$query as cts:and-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:and-query-options($query)
  => "ordered"

cts:and-query-queries(
$query as cts:and-query
)  as  cts:query*
Summary:

Returns a sequence of the queries that were used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:and-query-queries($query)
  => ... a sequence of the queries used to 
            construct this query
Example:
let $query := 
  cts:and-query((
    cts:word-query("to be or"), 
    cts:word-query("or not to be")))
return cts:and-query-queries($query)
  => (cts:word-query("to be or", (), 1) 
         cts:word-query("or not to be", (), 1))

cts:box(
$south as xs:float,
$west as xs:float,
$north as xs:float,
$east as xs:float
)  as  cts:box
Summary:

Returns a geospatial box value.

Parameters:
$south : The southern boundary of the box.
$west : The western boundary of the box.
$north : The northern boundary of the box.
$east : The eastern boundary of the box.

Example:
cts:box(-122, 78, 30, 45)
=> [-122, 78, 30, 45] (as a cts:box)

cts:box-east(
$box as cts:box
)  as  xs:float
Summary:

Returns a box's eastern boundary.

Parameters:
$box : The box.

Example:
cts:box-east(cts:box(-122, 78, 30, 45))
=> 45

cts:box-north(
$box as cts:box
)  as  xs:float
Summary:

Returns a box's northern boundary.

Parameters:
$box : The box.

Example:
cts:box-north(cts:box(-122, 78, 30, 45))
=> 30

cts:box-south(
$box as cts:box
)  as  xs:float
Summary:

Returns a box's southern boundary.

Parameters:
$box : The box.

Example:
cts:box-south(cts:box(-122, 78, 30, 45))
=> -122

cts:box-west(
$box as cts:box
)  as  xs:float
Summary:

Returns a box's western boundary.

Parameters:
$box : The box.

Example:
cts:box-west(cts:box(-122, 78, 30, 45))
=> 78

cts:circle(
$radius as xs:float,
$center as cts:point
)  as  cts:circle
Summary:

Returns a geospatial circle value.

Parameters:
$radius : The radius of the circle. The units for the radius is determined at runtime by the cts:query options (miles is currently the only option).
$center : A point representing the center of the circle.

Example:
cts:circle(20, cts:point(37.655983, -122.425525))
=> @20 37.656,-122.426 (as a cts:circle)

cts:circle-center(
$circle as cts:circle
)  as  cts:point
Summary:

Returns a circle's center point.

Parameters:
$circle : The circle.

Example:
cts:circle-center(cts:circle(20, cts:point(37.655983, -122.425525)))
=> 37.655983, -122.425525 (as a cts:point)

cts:circle-radius(
$circle as cts:circle
)  as  xs:float
Summary:

Returns a circle's radius.

Parameters:
$circle : The circle.

Example:
cts:circle-radius(cts:circle(20, cts:point(37.655983, -122.425525)))
=> 20

cts:collection-match(
$pattern as xs:string,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns values from the collection lexicon that match the specified wildcard pattern. This function requires the collection-lexicon database configuration parameter to be enabled. If the uri-lexicon database-configuration parameter is not enabled, an exception is thrown.

Parameters:
$pattern : Wildcard pattern to match.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
URIs should be returned in ascending order.
"descending"
URIs should be returned in descending order.
"any"
URIs from any fragment should be included.
"document"
URIs from document fragments should be included.
"properties"
URIs from properties fragments should be included.
"locks"
URIs from locks fragments should be included.
"frequency-order"
URIs should be returned ordered by frequency.
"item-order"
URIs should be returned ordered by item.
"sample=N"
Return only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include URIs from fragments selected by the cts:query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "sample=N" is not specfied in the options parameter, then all included URIs are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then URIs from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

If the $query parameter is not present and the current user is assigned the admin role, URIs from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see URIs from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:collection-match("collection*")
  => ("collection1", "collection2", ...)

cts:collection-query(
$uris as xs:string*
)  as  cts:collection-query
Summary:

Returns a query matching documents in the collections with the given URIs. It will match both documents and properties documents in the collections with the given URIs.

Parameters:
$uris : One or more collection URIs.

Example:
  cts:search(//function,
    cts:collection-query(("reports", "analysis")))
  
  => .. a sequence of 'function' elements in any document in the 
     collection "reports" or in the collection "analysis".
Example:
cts:search(//function, cts:and-query(("repair", 
    cts:collection-query(("reports", "analysis")))))
  
  => .. relevance ordered sequence of 'function' elements in 
     any document that both contains the word "repair" and is
     in either the collection "reports" or in the collection 
     "analysis".

cts:collection-query-uris(
$query as cts:collection-query
)  as  xs:string*
Summary:

Returns the URIs used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:collection-query-uris($query)
  => ("reports", "analysis")

cts:collections(
[$start as xs:string?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns values from the collection lexicon. This function requires the collection-lexicon database configuration parameter to be enabled. If the collection-lexicon database-configuration parameter is not enabled, an exception is thrown.

Parameters:
$start (optional): A starting value. Return only this value and following values. If the parameter is is not in the lexicon, then it returns the values beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
URIs should be returned in ascending order.
"descending"
URIs should be returned in descending order.
"any"
URIs from any fragment should be included.
"document"
URIs from document fragments should be included.
"properties"
URIs from properties fragments should be included.
"locks"
URIs from locks fragments should be included.
"frequency-order"
URIs should be returned ordered by frequency.
"item-order"
URIs should be returned ordered by item.
"sample=N"
Return only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include URIs from fragments selected by the cts:query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, URIs from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see URIs from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:collections("aardvark")
  => ("aardvark", "aardvarks", ...)

cts:confidence(
[$node as node()]
)  as  xs:float
Summary:

Returns the confidence of a node, or of the context node if no node is provided.

Parameters:
$node (optional): A node. Typically this is an item in the result sequence of a cts:search operation.

Usage Notes:

Confidence is similar to score, except that it is bounded. It is similar to fitness, except that it is influenced by term IDFs. It is an xs:float in the range of 0.0 to 1.0. It does not include quality.

When using with any of the scoring methods, the confidence is calculated by first bounding the score in the range of 0.0 to 1.0, then taking the square root of that number.


Example:
  let $x := cts:search(collection(), "dog")
  return
  cts:confidence($x[1])

   => Returns the confidence value for the first item
      in the search.

cts:contains(
$nodes as node()*,
$query as cts:query
)  as  xs:boolean?
Summary:

Returns true if any of a sequence of nodes matches a query.

Parameters:
$nodes : Some nodes to be checked for a match.
$query : A query to match against. If a string is entered, the string is treated as a cts:word-query of the specified string.

Example:
cts:contains(//PLAY
  [TITLE="The Tragedy of Hamlet, Prince of Denmark"]
      /ACT[3]/SCENE[1],
    cts:word-query("To be, or not to be"))
  => ..true, if ACT II, SCENE I of Hamlet contains
    the phrase "To be, or not to be" (it does).

cts:deregister(
$id as xs:unsignedLong
)  as  empty-sequence()
Summary:

Deregister a registered query, explicitly releasing the associated resources.

Parameters:
$id : A registered query identifier.

Example:
  cts:deregister(xs:unsignedLong("12345678901234567"))
  
   => ()

cts:directory-query(
$uris as xs:string*,
[$depth as xs:string]
)  as  cts:directory-query
Summary:

Returns a query matching documents in the directories with the given URIs.

Parameters:
$uris : One or more directory URIs.
$depth (optional): "1" for immediate children, "infinity" for all. If not supplied, depth is "1".

Example:
  cts:search(//function,
    cts:directory-query(("/reports/","/analysis/"),"1"))
  
  => .. a sequence of 'function' elements in any document 
     in the directory "/reports/" or the directory "/analysis/".
Example:
cts:search(//function, cts:and-query(("repair", 
  cts:directory-query(("/reports/", "/analysis/"), "1"))))
  
  => .. relevance ordered sequence of 'function' elements in 
     any document that both contains the word "repair" and is
     in either the directory "/reports/" or in the directory 
     "/analysis/".

cts:directory-query-depth(
$query as cts:directory-query
)  as  xs:string
Summary:

Returns the depth used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:directory-query-depth($query)
  => 1

cts:directory-query-uris(
$query as cts:directory-query
)  as  xs:string*
Summary:

Returns the URIs used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:directory-query-uris($query)
  => ("/reports", "/analysis/")

cts:distance(
$p1 as cts:point,
$p2 as cts:point,
[$options as xs:string*]
)  as  xs:double
Summary:

Returns the distance (in miles) between two points.

Parameters:
$p1 : The first point.
$p2 : The second point.
$options (optional): Options for the operation. The default is ().

Options include:

"coordinate-system=wgs84"
Use the WGS84 coordinate system.
"units=miles"
Distance is measured in miles.

Example:
let $sf := cts:point(37, -122)
let $ny := cts:point(40, -73)
return
cts:distance($sf, $ny)

=> 2626.42211914063

cts:document-query(
$uris as xs:string*
)  as  cts:document-query
Summary:

Returns a query matching documents with the given URIs. It will match both documents and properties documents with the given URIs.

Parameters:
$uris : One or more document URIs.

Example:
  cts:search(//function,
    cts:document-query("/reports.xml"))
  
  => .. relevance-ordered sequence of 'function' elements
  in the document "/reports.xml".
Example:
cts:search(//function, cts:and-query(("repair", 
  cts:document-query(("/reports.xml", "/analysis.xml")))))
  
  => .. relevance ordered sequence of 'function' elements in 
     any document that both contains the word "repair" and is
     in either the document "/reports.xml" or in the document 
     "/analysis.xml".

cts:document-query-uris(
$query as cts:document-query
)  as  xs:string*
Summary:

Returns the URIs used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:document-query-uris($query)
  => ("/reports.xml", "/analysis.xml")

cts:element-attribute-pair-geospatial-boxes(
$parent-element-names as xs:QName*,
$latitude-names as xs:QName*,
$longitude-names as xs:QName*,
[$latitude-bounds as xs:double*],
[$longitude-bounds as xs:double*],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:range)*
Summary:

Returns boxes derived from the specified element point lexicon(s). Element point lexicons are implemented using geospatial indexes; consequently this function requires a geospatial element attribute pair index for each prarent element and attribute pair specified in the function. If there is not a geospatial index configured for each of the specified combinations, an exception is thrown.

The points are divided into box-shaped buckets. The $latitude-bounds and $longitude-bounds parameters specify the number and the size of each box-shaped bucket. All included points are bucketed, even those outside the bounds. An empty sequence for both $latitude-bounds and $longitude-bounds specifies one bucket, a single value for both specifies four buckets, two values for both specify nine buckets, and so on.

For each non-empty bucket, a cts:box value is returned. By default, the cts:box value is the minimum bounding box of all the points in the bucket. If the "gridded" option is specified, then if a bucket is bounded on a side, its corresponding cts:box side is the bound. Empty buckets return nothing unless the "empties" option is specified.


Parameters:
$parent-element-names : One or more element QNames.
$latitude-names : One or more element QNames.
$longitude-names : One or more element QNames.
$latitude-bounds (optional): A sequence of latitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$longitude-bounds (optional): A sequence of longitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$options (optional): Options. The default is ().

Options include:

"ascending"
Boxes should be returned in ascending order.
"descending"
Boxes should be returned in descending order.
"gridded"
For each side that a bucket is bounded, return the corresponding bound as the edge of the box, instead of the extremum from the points in the bucket.
"empties"
Include fully-bounded ranges whose frequency is 0. Only empty ranges that have both their upper and lower bounds specified in the $bounds options are returned; any empty ranges that are less than the first bound or greater than the last bound are not returned. For example, if you specify 4 bounds and there are no results for any of the bounds, 3 elements are returned (not 5 elements).
"any"
Points from any fragment should be included.
"document"
Points from document fragments should be included.
"properties"
Points from properties fragments should be included.
"locks"
Points from locks fragments should be included.
"frequency-order"
Boxes should be returned ordered by frequency.
"item-order"
Boxes should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included point. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included point. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only boxes for buckets with at least one point from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only points from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include points in fragments selected by the cts:query. The points do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all boxes with included points are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then points from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, points from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see points from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 


cts:element-attribute-pair-geospatial-query(
$element-name as xs:QName*,
$latitude-attribute-names as xs:QName*,
$longitude-attribute-names as xs:QName*,
$regions as cts:region*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-attribute-pair-geospatial-query
Summary:

Returns a cts:query matching elements by name which has specific attributes representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception.

Parameters:
$element-name : One or more parent element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$latitude-attribute-names : One or more latitude attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching latitude attribute in any point instance will be checked.
$longitude-attribute-names : One or more longitude attribute QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching longitude attribute in any point instance will be checked.
$regions : One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches.
$options (optional): Options to this query. The default is ().

Options include:

"coordinate-system=wgs84"
Use the WGS84 coordinate system.
"units=miles"
Distance (for circles) is measured in miles.
"boundaries-included"
Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default.
"boundaries-excluded"
Points on boxes', circles', and polygons' boundaries are not counted as matching.
"boundaries-latitude-excluded"
Points on boxes' latitude boundaries are not counted as matching.
"boundaries-longitude-excluded"
Points on boxes' longitude boundaries are not counted as matching.
"boundaries-south-excluded"
Points on the boxes' southern boundaries are not counted as matching.
"boundaries-west-excluded"
Points on the boxes' western boundaries are not counted as matching.
"boundaries-north-excluded"
Points on the boxes' northern boundaries are not counted as matching.
"boundaries-east-excluded"
Points on the boxes' eastern boundaries are not counted as matching.
"boundaries-circle-excluded"
Points on circles' boundary are not counted as matching.
$weight (optional): A weight for this query. The default is 1.0. In release 4.0 this option is ignored; geospatial queries do not contribute to the score.

Usage Notes:

The point value is expressed as the numerical values in the textual content of the named attributes.

The point values and the boundary specifications are given in degrees relative to the WGS84 coordinate system. Southern latitudes and Western longitudes take negative values. Longitudes will be wrapped to the range (-180,+180) and latitudes will be clipped to the range (-90,+90).

If the northern boundary of a box is south of the southern boundary, no points will match. However, longitudes wrap around the globe, so that if the western boundary is east of the eastern boundary (that is, if the value of 'w' is greater than the value of 'e'), then the box crosses the anti-meridian.

Special handling occurs at the poles, as all longitudes exist at latitudes +90 and -90.


Example:
(: create a document with test data :)
xdmp:document-insert("/points.xml",
<root>
  <item><point lat="10.5" long="30.0"/></item>
  <item><point lat="15.35" long="35.34"/></item>
  <item><point lat="5.11" long="40.55"/></item>
</root> );

cts:search(doc("/points.xml")//item, 
  cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
    xs:QName("lat"), xs:QName("long"), cts:box(10.0, 35.0, 20.0, 40.0)))
(:
  returns the following node: 
  <item><point lat="15.35" long="35.34"/></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
    xs:QName("lat"), xs:QName("long"), cts:box(10.0, 40.0, 20.0, 35.0)))
(:
  returns the following nodes (wrapping around the Earth):
  <item><point lat="10.5" long="30.0"/></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
    xs:QName("lat"), xs:QName("long"), cts:box(20.0, 35.0, 10.0, 40.0)))
(:
  throws an error (latitudes do not wrap)
:)
;

cts:element-attribute-pair-geospatial-query-element-name(
$query as cts:element-attribute-pair-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-attribute-pair-geospatial-query-element-name($query)
  => xs:QName("point")

cts:element-attribute-pair-geospatial-query-latitude-name(
$query as cts:element-attribute-pair-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-attribute-pair-geospatial-query-latitude-name($query)
  => xs:QName("lat")

cts:element-attribute-pair-geospatial-query-longitude-name(
$query as cts:element-attribute-pair-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-attribute-pair-geospatial-query-longitude-name($query)
  => xs:QName("lat")

cts:element-attribute-pair-geospatial-query-options(
$query as cts:element-attribute-pair-geospatial-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-attribute-pair-geospatial-query-options($query)
  => "coordinate-system=wgs84"

cts:element-attribute-pair-geospatial-query-region(
$query as cts:element-attribute-pair-geospatial-query
)  as  cts:region*
Summary:

Returns the geographical regions with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-attribute-pair-geospatial-query-region($query)
  => cts:box(10.1, 10.2, 20.1, 20.2)

cts:element-attribute-pair-geospatial-query-weight(
$query as cts:element-attribute-pair-geospatial-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-attribute-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-attribute-pair-geospatial-query-weight($query)
  => 1

cts:element-attribute-pair-geospatial-value-match(
$element-names as xs:QName*,
$latitude-names as xs:QName*,
$longitude-names as xs:QName*,
$pattern as xs:anyAtomicType,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element attribute pair geospatial value lexicon(s) that match the specified wildcard pattern. Element attribute pair geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element attribute pair geospatial index for each combination of elements and attributes specified in the function. If there is not a geospatial index configured for each of the specified combinations, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$latitude-names : One or more latitude element QNames.
$longitude-names : One or more longitude element QNames.
$pattern : A pattern to match. The parameter type must match the lexicon type.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-attribute-pair-geospatial-value-match(
     xs:QName("location"),xs:QName("lat"),xs:QName("long"),cts:point(10,20))
  => 10,20

cts:element-attribute-pair-geospatial-values(
$element-names as xs:QName*,
$latitude-names as xs:QName*,
$longitude-names as xs:QName*,
[$start as cts:point?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  cts:point*
Summary:

Returns values from the specified element-attribute-pair geospatial value lexicon(s). element-attribute-pair geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element-attribute-pair geospatial index of for each of the combinatation specified in the function. If there is not a geospatial index configured for each of the specified combinations, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$latitude-names : One or more latitude element QNames.
$longitude-names : One or more longitude element QNames.
$start (optional): A starting value. If the parameter value is is not in the lexicon, then the values are returned beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

When multiple element and/or child QNames are specified, then all possible element/child QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-attribute-pair-geospatial-values(
     xs:QName("location"), xs:QName("position"), cts:point(0,0) )
  => (cts:point(0,0),cts:point(0,10),cts:point(0,20),...)

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
Summary:

Returns a cts:query matching elements by name with a range-index entry equal a given value. Searches with the cts:element-attribute-range-query constructor require an attribute range index on the specified QName(s); if there is no range index configured, then an exception is thrown.

Parameters:
$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.
$operator : A comparison operator.

Operators include:

"<"
Match range index values less than $value.
"<="
Match range index values less than or equal to $value.
">"
Match range index values greater than $value.
">="
Match range index values greater than or equal to $value.
"="
Match range index values equal to $value.
"!="
Match range index values not equal to $value.
$value : Some values to match. When multiple values are specified, the query matches if any value matches.
$options (optional): Options to this query. The default is ().

Options include:

"collation=URI"
Use the range index with the collation specified by URI. If not specified, then the default collation from the query is used. If a range index with the specified collation does not exist, an error is thrown.
$weight (optional): A weight for this query. The default is 1.0. In the current release, this option is ignored; range queries do not contribute to the score.

Usage Notes:

If you want to constrain on a range of values, you can combine multiple cts:element-attribute-range-query constructors together with cts:and-query or other composable cts:query constructors.


Example:
(: 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>
:)

cts:element-attribute-range-query-attribute-name(
$query as cts:element-attribute-range-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-attribute-range-query(
              xs:QName("function"),
              xs:QName("name"),
              "Mark Logic Corporation")
return cts:element-attribute-range-query-attribute-name($query)

  => xs:QName("name")

cts:element-attribute-range-query-element-name(
$query as cts:element-attribute-range-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-attribute-range-query(
              xs:QName("function"),
              xs:QName("name"),
              "Mark Logic Corporation")
return cts:element-attribute-range-query-element-name($query)

  => xs:QName("function")

cts:element-attribute-range-query-operator(
$query as cts:element-attribute-range-query
)  as  xs:anyAtomicType*
Summary:

Returns the operator used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-attribute-range-query-operator($query)
  => "<"

cts:element-attribute-range-query-options(
$query as cts:element-attribute-range-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:element-attribute-range-query-options($query)
  => "collation=http://marklogic.com/collation/"

cts:element-attribute-range-query-value(
$query as cts:element-attribute-range-query
)  as  xs:anyAtomicType*
Summary:

Returns the value used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-attribute-range-query-value($query)
  => 123

cts:element-attribute-range-query-weight(
$query as cts:element-attribute-range-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:element-attribute-range-query-weight($query)
  => 1

cts:element-attribute-value-co-occurrences(
$element-name-1 as xs:QName,
$attribute-name-1 as xs:QName?,
$element-name-2 as xs:QName,
$attribute-name-2 as xs:QName?,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:co-occurrence)*
Summary:

Returns value co-occurrences from the specified element or element-attribute value lexicon(s). Value lexicons are implemented using range indexes; consequently this function requires a range index for each element/attribute pairs specified in the function. If there is not a range index configured for each of the specified element or element/attribute pairs, then an exception is thrown.

Parameters:
$element-name-1 : An element QName.
$attribute-name-1 : An attribute QName or empty sequence. The empty sequence specifies an element lexicon.
$element-name-2 : An element QName.
$attribute-name-2 : An attribute QName or empty sequence. The empty sequence specifies an element lexicon.
$options (optional): Options. The default is ().

Options include:

"ascending"
Co-occurrences should be returned in ascending order.
"descending"
Co-occurrences should be returned in descending order.
"any"
Co-occurrences from any fragment should be included.
"document"
Co-occurrences from document fragments should be included.
"properties"
Co-occurrences from properties fragments should be included.
"locks"
Co-occurrences from locks fragments should be included.
"frequency-order"
Co-occurrences should be returned ordered by frequency.
"item-order"
Co-occurrences should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included co-occurrences. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included co-occurrence. This option is used with cts:frequency.
"type=type"
For both lexicons, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"type-1=type"
For the first lexicon, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"type-2=type"
For the second lexicon, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
For both lexicons, use the collation specified by URI.
"collation-1=URI"
For the first lexicon, use the collation specified by URI.
"collation-2=URI"
For the second lexicon, use the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"ordered"
Include co-occurrences only when the value from the first lexicon appears before the value from the second lexicon. Requires that word positions be enabled for both lexicons.
"proximity=N"
Include co-occurrences only when the values appear within N words of each other. Requires that word positions be enabled for both lexicons.
"sample=N"
Return only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include co-occurrences in fragments selected by the cts:query. The co-occurrences do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included co-occurrences are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then co-occurrences from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, co-occurrences from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see co-occurrences from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 


cts:element-attribute-value-geospatial-co-occurrences(
$element-name-1 as xs:QName,
$attribute-name-1 as xs:QName?,
$geo-element-name as xs:QName,
$child-name-1 as xs:QName?,
$child-name-2 as xs:QName?,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:co-occurrence)*
Summary:

Returns value co-occurrences from the specified element-attribute value lexicon with the specified geospatial lexicon. Value lexicons are implemented using range indexes; consequently this function requires a range index for the element and attribute pair specified in the function. If there is not a range index configured for the specified element and attribute pair, then an exception is thrown. Geospatial lexicons are implemented using geospatial indexes; consequently this function requires a geospatial index for the element/attribute combination specified in the function. If there is not a geospatial index configured for the specified element/attribute combination, then an exception is thrown.

Parameters:
$element-name-1 : An element QName.
$attribute-name-1 : An attribute QName.
$geo-element-name : An element QName.
$child-name-1 : An element or attribute QName or empty sequence. The empty sequence specifies an element geospatial lexicon.
$child-name-2 : An element or attribute QName or empty sequence. The empty sequence specifies either an element lexicon or an element-child geospatial lexicon.
$options (optional): Options. The default is ().

Options include:

"geospatial-format=format"
Use the kind of geospatial lexicon specified by format (element, element-child, element-pair, or element-attribute-pair). If neither of the child QNames is specified, the default is "element"; if only the first of the child QNames is specified, the default is "element-child:; if both child QNames are specified, the default is "element-pair". If the selection is not compatible with the number of geospatial QNames specified, an error is raised.
"ascending"
Co-occurrences should be returned in ascending order.
"descending"
Co-occurrences should be returned in descending order.
"any"
Co-occurrences from any fragment should be included.
"document"
Co-occurrences from document fragments should be included.
"properties"
Co-occurrences from properties fragments should be included.
"locks"
Co-occurrences from locks fragments should be included.
"frequency-order"
Co-occurrences should be returned ordered by frequency.
"item-order"
Co-occurrences should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included co-occurrences. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included co-occurrence. This option is used with cts:frequency.
"type=type"
For the non-geospatial lexicon, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
For the non-geospatial lexicon, use the collation specified by URI.
"coordinate-system=URI"
For the geospatial lexicons, use the coordinate system specified by name.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"ordered"
Include co-occurrences only when the value from the first lexicon appears before the value from the second lexicon. Requires that word positions be enabled for both lexicons.
"reversed"
Consider the second lexicon as the first and vice versa.
"proximity=N"
Include co-occurrences only when the values appear within N words of each other. Requires that word positions be enabled for both lexicons.
"sample=N"
Return only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include co-occurrences in fragments selected by the cts:query. The co-occurrences do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included co-occurrences are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then co-occurrences from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, co-occurrences from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see co-occurrences from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 


cts:element-attribute-value-match(
$element-names as xs:QName*,
$attribute-names as xs:QName*,
$pattern as xs:anyAtomicType,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element-attribute value lexicon(s) that match the specified pattern. Element-attribute value lexicons are implemented using range indexes; consequently this function requires an attribute range index for each of the element/attribute pairs specified in the function. If there is not a range index configured for each of the specified element/attribute pairs, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$attribute-names : One or more attribute QNames.
$pattern : A pattern to match. The parameter type must match the lexicon type. String parameters may include wildcard characters.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"item-order"
Values should be returned ordered by item.
"type=type"
Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
Use the range index with the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"sample=N"
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a range index with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

When multiple element and/or attribute QNames are specified, then all possible element/attribute QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:element-attribute-value-match(xs:QName("animals"),
                     xs:QName("name"),"aardvark*")
  => ("aardvark","aardvarks")

cts:element-attribute-value-query(
$element-name as xs:QName*,
$attribute-name as xs:QName*,
$text as xs:string*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-attribute-value-query
Summary:

Returns a query matching elements by name with attributes by name with text content equal a given phrase.

Parameters:
$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.
$text : One or more attribute values to match. When multiple strings are specified, the query matches if any string matches.
$options (optional): Options to this query. The default is ().

Options include:

"case-sensitive"
A case-sensitive query.
"case-insensitive"
A case-insensitive query.
"diacritic-sensitive"
A diacritic-sensitive query.
"diacritic-insensitive"
A diacritic-insensitive query.
"punctuation-sensitive"
A punctuation-sensitive query.
"punctuation-insensitive"
A punctuation-insensitive query.
"whitespace-sensitive"
A whitespace-sensitive query.
"whitespace-insensitive"
A whitespace-insensitive query.
"stemmed"
A stemmed query.
"unstemmed"
An unstemmed query.
"wildcarded"
A wildcarded query.
"unwildcarded"
An unwildcarded query.
"exact"
An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded".
"lang=iso639code"
Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

If neither "case-sensitive" nor "case-insensitive" is present, $text is used to determine case sensitivity. If $text contains no uppercase, it specifies "case-insensitive". If $text contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $text is used to determine diacritic sensitivity. If $text contains no diacritics, it specifies "diacritic-insensitive". If $text contains diacritics, it specifies "diacritic-sensitive".

If neither "punctuation-sensitive" nor "punctuation-insensitive" is present, $text is used to determine punctuation sensitivity. If $text contains no punctuation, it specifies "punctuation-insensitive". If $text contains punctuation, it specifies "punctuation-sensitive".

If neither "whitespace-sensitive" nor "whitespace-insensitive" is present, the query is "whitespace-insensitive".

If neither "stemmed" nor "unstemmed" is present, the database configuration determines stemming. If the database has "stemmed searches" enabled, it specifies "stemmed". Otherwise it specifies "unstemmed".

If neither "wildcarded" nor "unwildcarded" is present, the database configuration and $text determine wildcarding. If the database has any wildcard indexes enabled ("three character searches", "two character searches", "one character searches", or "trailing wildcard searches") and if $text contains either of the wildcard characters '?' or '*', it specifies "wildcarded". Otherwise it specifies "unwildcarded".

If neither "stemmed" nor "unstemmed" is present, then the database configuration determines if a query is run as "stemmed" (stemmed searches enabled) or "unstemmed" (word searches enabled and stemmed searches disabled). If the query is a wildcard query and is also a phrase query (contains two or more terms), then any wildcard terms in the query will be "unstemmed".

When multiple element and/or attribute QNames are specified, then all possible element/attribute QName combinations are used to select the matching values.


Example:
  cts:search(//module,
    cts:element-attribute-value-query(
      xs:QName("function"), 
      xs:QName("type"), 
      "Mark Logic Corporation"))
  
=> .. relevance-ordered sequence of 'module' element ancestors (or self) of 'function' elements that have an attribute 'type' whose value equals 'Mark Logic Corporation'.
Example:
  cts:search(//module,
    cts:and-query((
      cts:element-attribute-value-query(
        xs:QName("function"), 
        xs:QName("type"), 
        "Mark Logic Corporation",
        false(), true(), 0.5),
      cts:element-word-query(
        xs:QName("title"), 
        "faster"))))
  
=> .. relevance-ordered sequence of 'module' element ancestors (or self) of both: (a) 'function' elements with attribute 'type' whose value equals the string 'Mark Logic Corporation', ignoring embedded punctuation, AND (b) 'title' elements whose text content contains the word 'faster', with the results from (a) given weight 0.5, and the results from (b) given default weight 1.0.

cts:element-attribute-value-query-attribute-name(
$query as cts:element-attribute-value-query
)  as  xs:QName*
Summary:

Returns the attribute QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-attribute-value-query(
              xs:QName("function"),
              xs:QName("type"),
              "Mark Logic Corporation")
return 
  cts:element-attribute-value-query-attribute-name($query)

  => xs:QName("type")

cts:element-attribute-value-query-element-name(
$query as cts:element-attribute-value-query
)  as  xs:QName*
Summary:

Returns the element QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-attribute-value-query(
              xs:QName("function"),
              xs:QName("type"),
              "Mark Logic Corporation")
return 
  cts:element-attribute-value-query-element-name($query)

  => xs:QName("function")

cts:element-attribute-value-query-options(
$query as cts:element-attribute-value-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:element-attribute-value-query-options($query)
  => ("case-sensitive", "punctuation-insensitive")

cts:element-attribute-value-query-text(
$query as cts:element-attribute-value-query
)  as  xs:string*
Summary:

Returns the text used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-attribute-value-query-text($query)
  => "choice of law"

cts:element-attribute-value-query-weight(
$query as cts:element-attribute-value-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:element-attribute-value-query-weight($query)
  => 1

cts:element-attribute-value-ranges(
$element-names as xs:QName*,
$attribute-names as xs:QName*,
[$bounds as xs:anyAtomicType*],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:range)*
Summary:

Returns value ranges from the specified element-attribute value lexicon(s). Element-attribute value lexicons are implemented using indexes; consequently this function requires an attribute range index of for each of the element/attribute pairs specified in the function. If there is not a range index configured for each of the specified element/attribute pairs, then an exception is thrown.

The values are divided into buckets. The $bounds parameter specifies the number of buckets and the size of each bucket. All included values are bucketed, even those less than the lowest bound or greater than the highest bound. An empty sequence for $bounds specifies one bucket, a single value specifies two buckets, two values specify three buckets, and so on.

If you have string values and you pass a $bounds parameter as in the following call:

cts:element-value-ranges(xs:QName("myElement"), ("f", "m"))

The first bucket contains string values that are less than the string f, the second bucket contains string values greater than or equal to f but less than m, and the third bucket contains string values that are greater than or equal to m.

For each non-empty bucket, a cts:range element is returned. Each cts:range element has a cts:minimum child and a cts:maximum child. If a bucket is bounded, its cts:range element will also have a cts:lower-bound child if it is bounded from below, and a cts:upper-bound element if it is bounded from above. Empty buckets return nothing unless the "empties" option is specified.


Parameters:
$element-names : One or more element QNames.
$attribute-names : One or more attribute QNames.
$bounds (optional): A sequence of range bounds. The types must match the lexicon type. The values must be in strictly ascending order.
$options (optional): Options. The default is ().

Options include:

"ascending"
Ranges should be returned in ascending order.
"descending"
Ranges should be returned in descending order.
"empties"
Include fully-bounded ranges whose frequency is 0. These ranges will have no minimum or maximum value. Only empty ranges that have both their upper and lower bounds specified in the $bounds options are returned; any empty ranges that are less than the first bound or greater than the last bound are not returned. For example, if you specify 4 bounds and there are no results for any of the bounds, 3 elements are returned (not 5 elements).
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Ranges should be returned ordered by frequency.
"item-order"
Ranges should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"type=type"
Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
Use the range index with the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"sample=N"
Return only ranges for buckets with at least one value from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a range index with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then ranges with all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

When multiple element and/or attribute QNames are specified, then all possible element/attribute QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 


cts:element-attribute-values(
$element-names as xs:QName*,
$attribute-names as xs:QName*,
[$start as xs:anyAtomicType?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element-attribute value lexicon(s). Element-attribute value lexicons are implemented using indexes; consequently this function requires an attribute range index of for each of the element/attribute pairs specified in the function. If there is not a range index configured for each of the specified element/attribute pairs, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$attribute-names : One or more attribute QNames.
$start (optional): A starting value. The parameter type must match the lexicon type. If the parameter value is is not in the lexicon, then the values are returned beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"type=type"
Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
Use the range index with the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"sample=N"
Return only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a range index with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

When multiple element and/or attribute QNames are specified, then all possible element/attribute QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:element-attribute-values(xs:QName("animal"),
                               xs:QName("name"),
                               "aardvark")
  => ("aardvark","aardvarks","aardwolf",...)

cts:element-attribute-word-match(
$element-names as xs:QName*,
$attribute-names as xs:QName*,
$pattern as xs:string,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the specified element-attribute word lexicon(s) that match a wildcard pattern. This function requires an element-attribute word lexicon for each of the element/attribute pairs specified in the function. If there is not an element-attribute word lexicon configured for any of the specified element/attribute pairs, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$attribute-names : One or more attribute QNames.
$pattern : Wildcard pattern to match.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

When multiple element and/or attribute QNames are specified, then all possible element/attribute QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:element-word-match(xs:QName("animals"),"aardvark*")
  => ("aardvark","aardvarks")

cts:element-attribute-word-query(
$element-name as xs:QName*,
$attribute-name as xs:QName*,
$text as xs:string*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-attribute-word-query
Summary:

Returns a query matching elements by name with attributes by name with text content containing a given phrase.

Parameters:
$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.
$text : Some words or phrases to match. When multiple strings are specified, the query matches if any string matches.
$options (optional): Options to this query. The default is ().

Options include:

"case-sensitive"
A case-sensitive query.
"case-insensitive"
A case-insensitive query.
"diacritic-sensitive"
A diacritic-sensitive query.
"diacritic-insensitive"
A diacritic-insensitive query.
"punctuation-sensitive"
A punctuation-sensitive query.
"punctuation-insensitive"
A punctuation-insensitive query.
"whitespace-sensitive"
A whitespace-sensitive query.
"whitespace-insensitive"
A whitespace-insensitive query.
"stemmed"
A stemmed query.
"unstemmed"
An unstemmed query.
"wildcarded"
A wildcarded query.
"unwildcarded"
An unwildcarded query.
"exact"
An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded".
"lang=iso639code"
Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

If neither "case-sensitive" nor "case-insensitive" is present, $text is used to determine case sensitivity. If $text contains no uppercase, it specifies "case-insensitive". If $text contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $text is used to determine diacritic sensitivity. If $text contains no diacritics, it specifies "diacritic-insensitive". If $text contains diacritics, it specifies "diacritic-sensitive".

If neither "punctuation-sensitive" nor "punctuation-insensitive" is present, $text is used to determine punctuation sensitivity. If $text contains no punctuation, it specifies "punctuation-insensitive". If $text contains punctuation, it specifies "punctuation-sensitive".

If neither "whitespace-sensitive" nor "whitespace-insensitive" is present, the query is "whitespace-insensitive".

If neither "stemmed" nor "unstemmed" is present, the database configuration determines stemming. If the database has "stemmed searches" enabled, it specifies "stemmed". Otherwise it specifies "unstemmed".

If neither "wildcarded" nor "unwildcarded" is present, the database configuration and $text determine wildcarding. If the database has any wildcard indexes enabled ("three character searches", "two character searches", "one character searches", or "trailing wildcard searches") and if $text contains either of the wildcard characters '?' or '*', it specifies "wildcarded". Otherwise it specifies "unwildcarded".

If neither "stemmed" nor "unstemmed" is present, then the database configuration determines if a query is run as "stemmed" (stemmed searches enabled) or "unstemmed" (word searches enabled and stemmed searches disabled). If the query is a wildcard query and is also a phrase query (contains two or more terms), then any wildcard terms in the query will be "unstemmed".


Example:
  cts:search(//module,
    cts:element-attribute-word-query(
      xs:QName("function"), 
      xs:QName("type"), 
      "Mark Logic Corporation"))
  
=> .. relevance-ordered sequence of 'module' element ancestors of 'function' elements that have a 'type' attribute whose value contains the phrase 'Mark Logic Corporation'.
Example:
  cts:search(//module,
    cts:element-attribute-word-query(
      xs:QName("function"), 
      xs:QName("type"), 
      "Mark Logic Corporation", "case-insensitive"))
  
=> .. relevance-ordered sequence of 'module' element ancestors of 'function' elements that have a 'type' attribute whose value contains the phrase 'Mark Logic Corporation', or any other case-shift, like 'MARK Logic Corporation'.
Example:
  cts:search(//module,
    cts:and-query((
      cts:element-attribute-word-query(
        xs:QName("function"), 
        xs:QName("type"), 
        "Mark Logic Corporation",
        "punctuation-insensitive", 0.5),
      cts:element-word-query(
        xs:QName("title"), 
        "faster"))))
  
=> .. relevance-ordered sequence of 'module' element ancestors of both: (a) 'function' elements with 'type' attribute whose value contains the phrase 'Mark Logic Corporation', ignoring embedded punctuation, AND (b) 'title' elements whose text content contains the term 'faster', with the results of the first query given weight 0.5, as opposed to the default 1.0 for the second query.

cts:element-attribute-word-query-attribute-name(
$query as cts:element-attribute-word-query
)  as  xs:QName*
Summary:

Returns the attribute QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-attribute-word-query(
              xs:QName("function"),
              xs:QName("type"),
              "Mark Logic Corporation")
return 
  cts:element-attribute-word-query-attribute-name($query)

  => xs:QName("type")

cts:element-attribute-word-query-element-name(
$query as cts:element-attribute-word-query
)  as  xs:QName*
Summary:

Returns the element QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-attribute-word-query(
              xs:QName("function"),
              xs:QName("type"),
              "Mark Logic Corporation")
return 
  cts:element-attribute-word-query-element-name($query)

  => xs:QName("function")

cts:element-attribute-word-query-options(
$query as cts:element-attribute-word-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:element-attribute-word-query-options($query)
  => ("case-sensitive", "punctuation-insensitive")

cts:element-attribute-word-query-text(
$query as cts:element-attribute-word-query
)  as  xs:string*
Summary:

Returns the text used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-attribute-word-query-text($query)
  => "choice of law"

cts:element-attribute-word-query-weight(
$query as cts:element-attribute-word-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:element-attribute-word-query-weight($query)
  => 1

cts:element-attribute-words(
$element-names as xs:QName*,
$attribute-names as xs:QName*,
[$start as xs:string?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the specified element-attribute word lexicon(s). This function requires an element-attribute word lexicon for each of the element/attribute pairs specified in the function. If there is not an element/attribute word lexicon configured for any of the specified element/attribute pairs, then an exception is thrown. The words are returned in collation order.

Parameters:
$element-names : One or more element QNames.
$attribute-names : One or more attribute QNames.
$start (optional): A starting word. Returns only this word and any following words from the lexicon. If the parameter is not in the lexicon, then it returns the words beginning with the next word.
$options (optional): Options. The default is ().

Options include:

"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

When multiple element and/or attribute QNames are specified, then all possible element/attribute QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:element-attribute-words(xs:QName("animal"),
                              xs:QName("name"),
                              "aardvark")
  => ("aardvark","aardvarks","aardwolf",...)

cts:element-child-geospatial-boxes(
$parent-element-names as xs:QName*,
$child-element-names as xs:QName*,
[$latitude-bounds as xs:double*],
[$longitude-bounds as xs:double*],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:range)*
Summary:

Returns boxes derived from the specified element point lexicon(s). Element point lexicons are implemented using geospatial indexes; consequently this function requires an element child geospatial index for each element specified in the function. If there is not a geospatial index configured for each of the specified element/child combinations, an exception is thrown.

The points are divided into box-shaped buckets. The $latitude-bounds and $longitude-bounds parameters specify the number and the size of each box-shaped bucket. All included points are bucketed, even those outside the bounds. An empty sequence for both $latitude-bounds and $longitude-bounds specifies one bucket, a single value for both specifies four buckets, two values for both specify nine buckets, and so on.

For each non-empty bucket, a cts:box value is returned. By default, the cts:box value is the minimum bounding box of all the points in the bucket. If the "gridded" option is specified, then if a bucket is bounded on a side, its corresponding cts:box side is the bound. Empty buckets return nothing unless the "empties" option is specified.


Parameters:
$parent-element-names : One or more element QNames.
$child-element-names : One or more element QNames.
$latitude-bounds (optional): A sequence of latitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$longitude-bounds (optional): A sequence of longitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$options (optional): Options. The default is ().

Options include:

"ascending"
Boxes should be returned in ascending order.
"descending"
Boxes should be returned in descending order.
"gridded"
For each side that a bucket is bounded, return the corresponding bound as the edge of the box, instead of the extremum from the points in the bucket.
"empties"
Include fully-bounded ranges whose frequency is 0. Only empty ranges that have both their upper and lower bounds specified in the $bounds options are returned; any empty ranges that are less than the first bound or greater than the last bound are not returned. For example, if you specify 4 bounds and there are no results for any of the bounds, 3 elements are returned (not 5 elements).
"any"
Points from any fragment should be included.
"document"
Points from document fragments should be included.
"properties"
Points from properties fragments should be included.
"locks"
Points from locks fragments should be included.
"frequency-order"
Boxes should be returned ordered by frequency.
"item-order"
Boxes should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included point. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included point. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only boxes for buckets with at least one point from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only points from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include points in fragments selected by the cts:query. The points do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all boxes with included points are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then points from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, points from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see points from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 


cts:element-child-geospatial-query(
$parent-element-name as xs:QName*,
$child-element-names as xs:QName*,
$regions as cts:box*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-child-geospatial-query
Summary:

Returns a cts:query matching elements by name which has specific element children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception.

Parameters:
$parent-element-name : One or more parent element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$child-element-names : One or more child element QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching latitude child in any point instance will be checked. The element must specify both latitude and longitude coordinates.
$regions : One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches.
$options (optional): Options to this query. The default is ().

Options include:

"coordinate-system=wgs84"
Use the WGS84 coordinate system.
"units=miles"
Distance (for circles) is measured in miles.
"boundaries-included"
Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default.
"boundaries-excluded"
Points on boxes', circles', and polygons' boundaries are not counted as matching.
"boundaries-latitude-excluded"
Points on boxes' latitude boundaries are not counted as matching.
"boundaries-longitude-excluded"
Points on boxes' longitude boundaries are not counted as matching.
"boundaries-south-excluded"
Points on the boxes' southern boundaries are not counted as matching.
"boundaries-west-excluded"
Points on the boxes' western boundaries are not counted as matching.
"boundaries-north-excluded"
Points on the boxes' northern boundaries are not counted as matching.
"boundaries-east-excluded"
Points on the boxes' eastern boundaries are not counted as matching.
"boundaries-circle-excluded"
Points on circles' boundary are not counted as matching.
$weight (optional): A weight for this query. The default is 1.0. In release 4.0 this option is ignored; geospatial queries do not contribute to the score.

Usage Notes:

The point value is expressed in the content of the element as a child of numbers, separated by whitespace and punctuation (excluding decimal points and sign characters).

Point values and boundary specifications of boxes are given in degrees relative to the WGS84 coordinate system. Southern latitudes and Western longitudes take negative values. Longitudes will be wrapped to the range (-180,+180) and latitudes will be clipped to the range (-90,+90).

If the northern boundary of a box is south of the southern boundary, no points will match. However, longitudes wrap around the globe, so that if the western boundary is east of the eastern boundary, then the box crosses the anti-meridian.

Special handling occurs at the poles, as all longitudes exist at latitudes +90 and -90.


Example:
(: create a document with test data :)
xdmp:document-insert("/points.xml",
<root>
  <item><point><pos>10.5 30.0</pos></point></item>
  <item><point><pos>15.35 35.34</pos></point></item>
  <item><point><pos>5.11 40.55</pos></point></item>
</root> );

cts:search(doc("/points.xml")//item,
  cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
    cts:box(10.0, 35.0, 20.0, 40.0)))
(:
  returns the following node: 
  <item><point><pos>15.35 35.34</pos></point></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
    cts:box(10.0, 40.0, 20.0, 35.0)))
(:
  returns the following nodes (wrapping around the Earth):
  <item><point><pos>10.5 30.0</pos></point></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
    cts:box(20.0, 35.0, 10.0, 40.0)))
(:
  throws an error (latitudes do not wrap)
:)
;

cts:element-child-geospatial-query-child-name(
$query as cts:element-child-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
     cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-child-geospatial-query-child-name($query)
  => xs:QName("pos")

cts:element-child-geospatial-query-element-name(
$query as cts:element-child-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
     cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-child-geospatial-query-element-name($query)
  => xs:QName("point")

cts:element-child-geospatial-query-options(
$query as cts:element-child-geospatial-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
     cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-child-geospatial-query-options($query)
  => "coordinate-system=wgs84"

cts:element-child-geospatial-query-region(
$query as cts:element-child-geospatial-query
)  as  cts:region*
Summary:

Returns the geographical regions with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
     cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-child-geospatial-query-region($query)
  => cts:box(10.1, 10.2, 20.1, 20.2)

cts:element-child-geospatial-query-weight(
$query as cts:element-child-geospatial-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-child-geospatial-query(xs:QName("point"), xs:QName("pos"),
     cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-child-geospatial-query-weight($query)
  => 1

cts:element-child-geospatial-value-match(
$element-names as xs:QName*,
$child-names as xs:QName*,
$pattern as xs:anyAtomicType,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element child geospatial value lexicon(s) that match the specified wildcard pattern. Element child geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element child geospatial index for each element and child specified in the function. If there is not a geospatial index configured for each of the specified elements/child combinations, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$child-names : One or more child element QNames.
$pattern : A pattern to match. The parameter type must match the lexicon type.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-child-geospatial-value-match(
     xs:QName("location"),xs:QName("pos"),cts:point(10,20))
  => 10,20

cts:element-child-geospatial-values(
$element-names as xs:QName*,
$child-names as xs:QName*,
[$start as cts:point?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  cts:point*
Summary:

Returns values from the specified element-child geospatial value lexicon(s). Element-child geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element-child geospatial index of for each of the element/child pairs specified in the function. If there is not a range index configured for each of the specified element/child pairs, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$child-names : One or more child element QNames.
$start (optional): A starting value. If the parameter value is is not in the lexicon, then the values are returned beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

When multiple element and/or child QNames are specified, then all possible element/child QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-child-geospatial-values(
     xs:QName("location"), xs:QName("position"), cts:point(0,0) )
  => (cts:point(0,0),cts:point(0,10),cts:point(0,20),...)

cts:element-geospatial-boxes(
$element-names as xs:QName*,
[$latitude-bounds as xs:double*],
[$longitude-bounds as xs:double*],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:range)*
Summary:

Returns boxes derived from the specified element point lexicon(s). Element point lexicons are implemented using geospatial indexes; consequently this function requires an element geospatial index for each element specified in the function. If there is not a geospatial index configured for each of the specified elements, an exception is thrown.

The points are divided into box-shaped buckets. The $latitude-bounds and $longitude-bounds parameters specify the number and the size of each box-shaped bucket. All included points are bucketed, even those outside the bounds. An empty sequence for both $latitude-bounds and $longitude-bounds specifies one bucket, a single value for both specifies four buckets, two values for both specify nine buckets, and so on.

For each non-empty bucket, a cts:box value is returned. By default, the cts:box value is the minimum bounding box of all the points in the bucket. If the "gridded" option is specified, then if a bucket is bounded on a side, its corresponding cts:box side is the bound. Empty buckets return nothing unless the "empties" option is specified.


Parameters:
$element-names : One or more element QNames.
$latitude-bounds (optional): A sequence of latitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$longitude-bounds (optional): A sequence of longitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$options (optional): Options. The default is ().

Options include:

"ascending"
Boxes should be returned in ascending order.
"descending"
Boxes should be returned in descending order.
"gridded"
For each side that a bucket is bounded, return the corresponding bound as the edge of the box, instead of the extremum from the points in the bucket.
"empties"
Include fully-bounded ranges whose frequency is 0. Only empty ranges that have both their upper and lower bounds specified in the $bounds options are returned; any empty ranges that are less than the first bound or greater than the last bound are not returned. For example, if you specify 4 bounds and there are no results for any of the bounds, 3 elements are returned (not 5 elements).
"any"
Points from any fragment should be included.
"document"
Points from document fragments should be included.
"properties"
Points from properties fragments should be included.
"locks"
Points from locks fragments should be included.
"frequency-order"
Boxes should be returned ordered by frequency.
"item-order"
Boxes should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included point. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included point. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only boxes for buckets with at least one point from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only points from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include points in fragments selected by the cts:query. The points do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all boxes with included points are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then points from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, points from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see points from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 


cts:element-geospatial-query(
$element-name as xs:QName*,
$regions as cts:region*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-geospatial-query
Summary:

Returns a cts:query matching elements by name whose content represents a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception.

Parameters:
$element-name : One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$regions : One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches.
$options (optional): Options to this query. The default is ().

Options include:

"coordinate-system=wgs84"
Use the WGS84 coordinate system.
"units=miles"
Distance (for circles) is measured in miles.
"boundaries-included"
Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default.
"boundaries-excluded"
Points on boxes', circles', and polygons' boundaries are not counted as matching.
"boundaries-latitude-excluded"
Points on boxes' latitude boundaries are not counted as matching.
"boundaries-longitude-excluded"
Points on boxes' longitude boundaries are not counted as matching.
"boundaries-south-excluded"
Points on the boxes' southern boundaries are not counted as matching.
"boundaries-west-excluded"
Points on the boxes' western boundaries are not counted as matching.
"boundaries-north-excluded"
Points on the boxes' northern boundaries are not counted as matching.
"boundaries-east-excluded"
Points on the boxes' eastern boundaries are not counted as matching.
"boundaries-circle-excluded"
Points on circles' boundary are not counted as matching.
$weight (optional): A weight for this query. The default is 1.0. In release 4.0 this option is ignored; geospatial queries do not contribute to the score.

Usage Notes:

The point value is expressed in the content of the element as a pair of numbers, separated by whitespace and punctuation (excluding decimal points and sign characters).

Point values and boundary specifications of boxes are given in degrees relative to the WGS84 coordinate system. Southern latitudes and Western longitudes take negative values. Longitudes will be wrapped to the range (-180,+180) and latitudes will be clipped to the range (-90,+90).

If the northern boundary of a box is south of the southern boundary, no points will match. However, longitudes wrap around the globe, so that if the western boundary is east of the eastern boundary, then the box crosses the anti-meridian.

Special handling occurs at the poles, as all longitudes exist at latitudes +90 and -90.


Example:
(: create a document with test data :)
xdmp:document-insert("/points.xml",
<root>
  <item><point>10.5, 30.0</point></item>
  <item><point>15.35, 35.34</point></item>
  <item><point>5.11, 40.55</point></item>
</root> );

cts:search(doc("/points.xml")//item, 
  cts:element-geospatial-query(xs:QName("point"), cts:box(10.0, 35.0, 20.0, 40.0)))
(:
  returns the following node: 
  <item><point>15.35, 35.34</point></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-geospatial-query(xs:QName("point"), cts:box(10.0, 40.0, 20.0, 35.0)))
(:
  returns the following nodes (wrapping around the Earth):
  <item><point>10.5, 30.0</point></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-geospatial-query(xs:QName("point"), cts:box(20.0, 35.0, 10.0, 40.0)))
(:
  throws an error (latitudes do not wrap)
:)
;

cts:element-geospatial-query-element-name(
$query as cts:element-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-geospatial-query(xs:QName("point"), cts:box(10.1, 10.2, 20.1, 20.2))
return
cts:element-geospatial-query-element-name($query)
  => xs:QName("point")

cts:element-geospatial-query-options(
$query as cts:element-geospatial-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-geospatial-query(xs:QName("point"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-geospatial-query-options($query)
  => "coordinate-system=wgs84"

cts:element-geospatial-query-region(
$query as cts:element-geospatial-query
)  as  cts:box*
Summary:

Returns the geographical regions with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-geospatial-query(xs:QName("point"),
       cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-geospatial-query-region($query)
  => cts:box(10.1, 10.2, 20.1, 20.2)

cts:element-geospatial-query-weight(
$query as cts:element-geospatial-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-geospatial-query(xs:QName("point"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-geospatial-query-weight($query)
  => 1

cts:element-geospatial-value-match(
$element-names as xs:QName*,
$pattern as xs:anyAtomicType,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element geospatial value lexicon(s) that match the specified wildcard pattern. Element geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element geospatial index for each element specified in the function. If there is not a geospatial index configured for each of the specified elements, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$pattern : A pattern to match. The parameter type must match the lexicon type.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-geospatial-value-match(xs:QName("point"),cts:point(10,20))
  => 10,20

cts:element-geospatial-values(
$element-names as xs:QName*,
[$start as cts:point?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  cts:point*
Summary:

Returns values from the specified element geospatial value lexicon(s). Geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element geospatial index for each element specified in the function. If there is not a geospatial index configured for each of the specified elements, an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$start (optional): A starting value. If the parameter value is is not in the lexicon, then the values are returned beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-geospatial-values(xs:QName("point"),cts:point(0,0))
  => (cts:point(0,0),cts:point(0,10),cts:point(0,20),...)

cts:element-pair-geospatial-boxes(
$parent-element-names as xs:QName*,
$latitude-names as xs:QName*,
$longitude-names as xs:QName*,
[$latitude-bounds as xs:double*],
[$longitude-bounds as xs:double*],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:range)*
Summary:

Returns boxes derived from the specified element point lexicon(s). Element point lexicons are implemented using geospatial indexes; consequently this function requires a geospatial element pair index for each parent and pair of child elements specified in the function. If there is not a geospatial index configured for each of the specified combinations, an exception is thrown.

The points are divided into box-shaped buckets. The $latitude-bounds and $longitude-bounds parameters specify the number and the size of each box-shaped bucket. All included points are bucketed, even those outside the bounds. An empty sequence for both $latitude-bounds and $longitude-bounds specifies one bucket, a single value for both specifies four buckets, two values for both specify nine buckets, and so on.

For each non-empty bucket, a cts:box value is returned. By default, the cts:box value is the minimum bounding box of all the points in the bucket. If the "gridded" option is specified, then if a bucket is bounded on a side, its corresponding cts:box side is the bound. Empty buckets return nothing unless the "empties" option is specified.


Parameters:
$parent-element-names : One or more element QNames.
$latitude-names : One or more element QNames.
$longitude-names : One or more element QNames.
$latitude-bounds (optional): A sequence of latitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$longitude-bounds (optional): A sequence of longitude bounds. The values must be in strictly ascending order, otherwise an exception is thrown.
$options (optional): Options. The default is ().

Options include:

"ascending"
Boxes should be returned in ascending order.
"descending"
Boxes should be returned in descending order.
"gridded"
For each side that a bucket is bounded, return the corresponding bound as the edge of the box, instead of the extremum from the points in the bucket.
"empties"
Include fully-bounded ranges whose frequency is 0. Only empty ranges that have both their upper and lower bounds specified in the $bounds options are returned; any empty ranges that are less than the first bound or greater than the last bound are not returned. For example, if you specify 4 bounds and there are no results for any of the bounds, 3 elements are returned (not 5 elements).
"any"
Points from any fragment should be included.
"document"
Points from document fragments should be included.
"properties"
Points from properties fragments should be included.
"locks"
Points from locks fragments should be included.
"frequency-order"
Boxes should be returned ordered by frequency.
"item-order"
Boxes should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included point. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included point. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only boxes for buckets with at least one point from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only points from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include points in fragments selected by the cts:query. The points do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all boxes with included points are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then points from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, points from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see points from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 


cts:element-pair-geospatial-query(
$element-name as xs:QName*,
$latitude-element-names as xs:QName*,
$longitude-element-names as xs:QName*,
$regions as cts:box*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-pair-geospatial-query
Summary:

Returns a cts:query matching elements by name which has specific element children representing latitude and longitude values for a point contained within the given geographic box, circle, or polygon, or equal to the given point. Points that lie between the southern boundary and the northern boundary of a box, travelling northwards, and between the western boundary and the eastern boundary of the box, travelling eastwards, will match. Points contained within the given radius of the center point of a circle will match, using the curved distance on the surface of the Earth. Points contained within the given polygon will match, using great circle arcs over a spherical model of the Earth as edges. An error may result if the polygon is malformed in some way. Points equal to the a given point will match, taking into account the fact that longitudes converge at the poles. Using the geospatial query constructors requires a valid geospatial license key; without a valid license key, searches that include geospatial queries will throw an exception.

Parameters:
$element-name : One or more parent element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$latitude-element-names : One or more latitude element QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching latitude child in any point instance will be checked.
$longitude-element-names : One or more longitude element QNames to match. When multiple QNames are specified, the query matches if any QName matches; however, only the first matching longitude child in any point instance will be checked.
$regions : One or more geographic boxes, circles, polygons, or points. Where multiple regions are specified, the query matches if any region matches.
$options (optional): Options to this query. The default is ().

Options include:

"coordinate-system=wgs84"
Use the WGS84 coordinate system.
"units=miles"
Distance (for circles) is measured in miles.
"boundaries-included"
Points on boxes', circles', and polygons' boundaries are counted as matching. This is the default.
"boundaries-excluded"
Points on boxes', circles', and polygons' boundaries are not counted as matching.
"boundaries-latitude-excluded"
Points on boxes' latitude boundaries are not counted as matching.
"boundaries-longitude-excluded"
Points on boxes' longitude boundaries are not counted as matching.
"boundaries-south-excluded"
Points on the boxes' southern boundaries are not counted as matching.
"boundaries-west-excluded"
Points on the boxes' western boundaries are not counted as matching.
"boundaries-north-excluded"
Points on the boxes' northern boundaries are not counted as matching.
"boundaries-east-excluded"
Points on the boxes' eastern boundaries are not counted as matching.
"boundaries-circle-excluded"
Points on circles' boundary are not counted as matching.
$weight (optional): A weight for this query. The default is 1.0. In release 4.0 this option is ignored; geospatial queries do not contribute to the score.

Usage Notes:

The point value is expressed in the content of the element as a pair of numbers, separated by whitespace and punctuation (excluding decimal points and sign characters).

Point values and boundary specifications of boxes are given in degrees relative to the WGS84 coordinate system. Southern latitudes and Western longitudes take negative values. Longitudes will be wrapped to the range (-180,+180) and latitudes will be clipped to the range (-90,+90).

If the northern boundary of a box is south of the southern boundary, no points will match. However, longitudes wrap around the globe, so that if the western boundary is east of the eastern boundary, then the box crosses the anti-meridian.

Special handling occurs at the poles, as all longitudes exist at latitudes +90 and -90.


Example:
(: create a document with test data :)
xdmp:document-insert("/points.xml",
<root>
  <item><point><lat>10.5</lat><long>30.0</long></point></item>
  <item><point><lat>15.35</lat><long>35.34</long></point></item>
  <item><point><lat>5.11</lat><long>40.55</long></point></item>
</root> );

cts:search(doc("/points.xml")//item, 
  cts:element-pair-geospatial-query(xs:QName("point"), 
    xs:QName("lat"), xs:QName("long"), cts:box(10.0, 35.0, 20.0, 40.0)))
(:
  returns the following node: 
  <item><point><lat>15.35</lat><long>35.34</long></point></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-pair-geospatial-query(xs:QName("point"), 
    xs:QName("lat"), xs:QName("long"), cts:box(10.0, 40.0, 20.0, 35.0)))
(:
  returns the following nodes (wrapping around the Earth):
  <item><point><lat>10.5</lat><long>30.0</long></point></item>
:)
;

cts:search(doc("/points.xml")//item, 
  cts:element-pair-geospatial-query(xs:QName("point"), 
    xs:QName("lat"), xs:QName("long"), cts:box(20.0, 35.0, 10.0, 40.0)))
(:
  throws an error (latitudes do not wrap)
:)
;

cts:element-pair-geospatial-query-element-name(
$query as cts:element-pair-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-pair-geospatial-query-element-name($query)
  => xs:QName("point")

cts:element-pair-geospatial-query-latitude-name(
$query as cts:element-pair-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-pair-geospatial-query-latitude-name($query)
  => xs:QName("lat")

cts:element-pair-geospatial-query-longitude-name(
$query as cts:element-pair-geospatial-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-pair-geospatial-query-longitude-name($query)
  => xs:QName("lat")

cts:element-pair-geospatial-query-options(
$query as cts:element-pair-geospatial-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-pair-geospatial-query-options($query)
  => "coordinate-system=wgs84"

cts:element-pair-geospatial-query-region(
$query as cts:element-pair-geospatial-query
)  as  cts:region*
Summary:

Returns the geographical regions with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-pair-geospatial-query-region($query)
  => cts:box(10.1, 10.2, 20.1, 20.2)

cts:element-pair-geospatial-query-weight(
$query as cts:element-pair-geospatial-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := 
   cts:element-pair-geospatial-query(xs:QName("point"), 
     xs:QName("lat"), xs:QName("long"), cts:box(10.1, 10.2, 20.1, 20.2))
return cts:element-pair-geospatial-query-weight($query)
  => 1

cts:element-pair-geospatial-value-match(
$element-names as xs:QName*,
$latitude-names as xs:QName*,
$longitude-names as xs:QName*,
$pattern as xs:anyAtomicType,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element pair geospatial value lexicon(s) that match the specified wildcard pattern. Element pair geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element pair geospatial index for each combination of elements specified in the function. If there is not a geospatial index configured for each of the specified combinations, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$latitude-names : One or more latitude element QNames.
$longitude-names : One or more longitude element QNames.
$pattern : A pattern to match. The parameter type must match the lexicon type.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-pair-geospatial-value-match(
     xs:QName("location"),xs:QName("lat"),xs:QName("long"),cts:point(10,20))
  => 10,20

cts:element-pair-geospatial-values(
$element-names as xs:QName*,
$latitude-names as xs:QName*,
$longitude-names as xs:QName*,
[$start as cts:point?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  cts:point*
Summary:

Returns values from the specified element-pair geospatial value lexicon(s). element-pair geospatial value lexicons are implemented using geospatial indexes; consequently this function requires an element-pair geospatial index of for each of the combinatation specified in the function. If there is not a geospatial index configured for each of the specified combinations, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$latitude-names : One or more latitude element QNames.
$longitude-names : One or more longitude element QNames.
$start (optional): A starting value. If the parameter value is is not in the lexicon, then the values are returned beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"coordinate-system=URI"
Use the lexicon with the coordinate system specified by name.
"sample=N"
Return only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

When multiple element and/or child QNames are specified, then all possible element/child QName combinations are used to select the matching values.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 

Example:
  cts:element-pair-geospatial-values(
     xs:QName("location"), xs:QName("position"), cts:point(0,0) )
  => (cts:point(0,0),cts:point(0,10),cts:point(0,20),...)

cts:element-query(
$element-name as xs:QName*,
$query as cts:query
)  as  cts:element-query
Summary:

Returns a cts:query matching elements by name with the content constrained by the given cts:query in the second parameter. Searches for matches in the specified element and all of its descendants. If the specified query in the second parameter has any cts:element-attribute-*-query constructors, it will search attributes directly on the specified element and attributes on any descendant elements (see the second example below).

Parameters:
$element-name : One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$query : A query for the element to match. If a string is entered, the string is treated as a cts:word-query of the specified string.

Usage Notes:

Enabling both the word position and element position indexes ("word position" and "element word position" in the database configuration screen of the Admin Interface) will speed up query performance for many queries that use cts:element-query. The position indexes enable MarkLogic Server to eliminate many false-positive resultss, which can reduce disk I/O and processing, thereby speeding the performance of many queries. The amount of benefit will vary depending on your data.

Example:
  cts:search(//module,
    cts:element-query(
      xs:QName("function"), 
      "Mark Logic Corporation"))
  
=> .. relevance-ordered sequence of 'module' elements ancestors (or self) of elements with QName 'function' and text content containing the phrase 'Mark Logic Corporation'.
Example:
let $x := <a attr="something">hello</a>
return
cts:contains($x, cts:element-query(xs:QName("a"), 
   cts:and-query((
     cts:element-attribute-word-query(xs:QName("a"), 
         xs:QName("attr"), "something"),
     cts:word-query("hello")))))
(: returns true :)

cts:element-query-element-name(
$query as cts:element-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-query(
              xs:QName("function"),
              "Mark Logic Corporation")
return cts:element-query-element-name($query)

  => xs:QName("function")

cts:element-query-query(
$query as cts:element-query
)  as  cts:query
Summary:

Returns the query used to construct the element query.

Parameters:
$query : A query.

Example:
let $query := cts:element-query(
                 cts:word-query("wanted"))
return cts:element-query-query($query)
  
  => cts:word-query("wanted", (), 1)

cts:element-range-query(
$element-name as xs:QName*,
$operator as xs:string,
$value as xs:anyAtomicType*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-range-query
Summary:

Returns a cts:query matching elements by name with a range-index entry equal a given value. Searches with the cts:element-range-query constructor require an element range index on the specified QName(s); if there is no range index configured, then an exception is thrown.

Parameters:
$element-name : One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$operator : A comparison operator.

Operators include:

"<"
Match range index values less than $value.
"<="
Match range index values less than or equal to $value.
">"
Match range index values greater than $value.
">="
Match range index values greater than or equal to $value.
"="
Match range index values equal to $value.
"!="
Match range index values not equal to $value.
$value : One or more element values to match. When multiple values are specified, the query matches if any value matches.
$options (optional): Options to this query. The default is ().

Options include:

"collation=URI"
Use the range index with the collation specified by URI. If not specified, then the default collation from the query is used. If a range index with the specified collation does not exist, an error is thrown.
$weight (optional): A weight for this query. The default is 1.0. In the current release, this option is ignored; range queries do not contribute to the score.

Usage Notes:

If you want to constrain on a range of values, you can combine multiple cts:element-range-query constructors together with cts:and-query or any of the other composable cts:query constructors, as in the last part of the example below.


Example:
(: create a document with test data :)
xdmp:document-insert("/dates.xml",
<root>
  <entry>
    <date>2007-01-01</date>
    <info>Some information.</info>
  </entry>
  <entry>
    <date>2006-06-23</date>
    <info>Some other information.</info>
  </entry>
  <entry>
    <date>1971-12-23</date>
    <info>Some different information.</info>
  </entry>
</root>);

(: 
   requires an element (range) index of 
   type xs:date on "date" 
:)
cts:search(doc("/dates.xml")/root/entry, 
  cts:element-range-query(xs:QName("date"), "<=",
      xs:date("2000-01-01")))
(:
  returns the following node: 
  <entry>
    <date>1971-12-23</date>
    <info>Some different information.</info>
  </entry>
:)
;
(: 
   requires an element (range) index of 
   type xs:date on "date" 
:)
cts:search(doc("/dates.xml")/root/entry, 
  cts:and-query((
   cts:element-range-query(xs:QName("date"), ">",
      xs:date("2006-01-01")),
   cts:element-range-query(xs:QName("date"), "<",
      xs:date("2008-01-01")))))
(:
  returns the following 2 nodes: 
  <entry>
    <date>2007-01-01</date>
    <info>Some information.</info>
  </entry>

  <entry>
    <date>2006-06-23</date>
    <info>Some other information.</info>
  </entry>
:)

cts:element-range-query-element-name(
$query as cts:element-range-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
cts:element-range-query-element-name($query)
  => xs:QName("function")

cts:element-range-query-operator(
$query as cts:element-range-query
)  as  xs:anyAtomicType*
Summary:

Returns the operator used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-range-query-operator($query)
  => "<"

cts:element-range-query-options(
$query as cts:element-range-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:element-range-query-options($query)
  => "collation=http://marklogic.com/collation/"

cts:element-range-query-value(
$query as cts:element-range-query
)  as  xs:anyAtomicType*
Summary:

Returns the value used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-range-query-value($query)
  => 123

cts:element-range-query-weight(
$query as cts:element-range-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:element-range-query-weight($query)
  => 1

cts:element-value-co-occurrences(
$element-name-1 as xs:QName,
$element-name-2 as xs:QName,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:co-occurrence)*
Summary:

Returns value co-occurrences (that is, pairs of values, both of which appear in the same fragment) from the specified element value lexicon(s). The values are returned as an XML element with two children, each child containing one of the co-occurring values. You can use cts:frequency on each item returned to find how many times the pair occurs. Value lexicons are implemented using range indexes; consequently this function requires an element range index for each element specified in the function, and the range index must have range value positions set to true. If there is not a range index configured for each of the specified elements, and if the range value positions is not enabled for the any of the range indexes, an exception is thrown.

Parameters:
$element-name-1 : An element QName.
$element-name-2 : An element QName.
$options (optional): Options. The default is ().

Options include:

"ascending"
Co-occurrences should be returned in ascending order.
"descending"
Co-occurrences should be returned in descending order.
"any"
Co-occurrences from any fragment should be included.
"document"
Co-occurrences from document fragments should be included.
"properties"
Co-occurrences from properties fragments should be included.
"locks"
Co-occurrences from locks fragments should be included.
"frequency-order"
Co-occurrences should be returned ordered by frequency.
"item-order"
Co-occurrences should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included co-occurrences. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included co-occurrence. This option is used with cts:frequency.
"type=type"
For both lexicons, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"type-1=type"
For the first lexicon, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"type-2=type"
For the second lexicon, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
For both lexicons, use the collation specified by URI.
"collation-1=URI"
For the first lexicon, use the collation specified by URI.
"collation-2=URI"
For the second lexicon, use the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"ordered"
Include co-occurrences only when the value from the first lexicon appears before the value from the second lexicon. Requires that word positions be enabled for both lexicons.
"proximity=N"
Include co-occurrences only when the values appear within N words of each other. Requires that word positions be enabled for both lexicons.
"sample=N"
Return only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include co-occurrences in fragments selected by the cts:query. The co-occurrences do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included co-occurrences are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then co-occurrences from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, co-occurrences from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see co-occurrences from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  (: this query has the database fragmented on SPEECH and 
     finds SPEAKERs that co-occur in a SPEECH :)
  cts:element-value-co-occurrences(
    xs:QName("SPEAKER"),xs:QName("SPEAKER"),
    ("frequency-order","ordered"),
    cts:document-query("hamlet.xml"))[1 to 3]
  => 
  <cts:co-occurrence xmlns:cts="http://marklogic.com/cts" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <cts:value xsi:type="xs:string">MARCELLUS</cts:value>
    <cts:value xsi:type="xs:string">BERNARDO</cts:value>
  </cts:co-occurrence>
  <cts:co-occurrence xmlns:cts="http://marklogic.com/cts"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <cts:value xsi:type="xs:string">ROSENCRANTZ</cts:value>
    <cts:value xsi:type="xs:string">GUILDENSTERN</cts:value>
  </cts:co-occurrence>
  <cts:co-occurrence xmlns:cts="http://marklogic.com/cts"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <cts:value xsi:type="xs:string">HORATIO</cts:value>
    <cts:value xsi:type="xs:string">MARCELLUS</cts:value>
  </cts:co-occurrence>


cts:element-value-geospatial-co-occurrences(
$element-name-1 as xs:QName,
$geo-element-name as xs:QName,
$child-name-1 as xs:QName?,
$child-name-2 as xs:QName?,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:co-occurrence)*
Summary:

Returns value co-occurrences from the specified element value lexicon with the specified geospatial lexicon. Value lexicons are implemented using range indexes; consequently this function requires a range index for the element specified in the function. If there is not a range index configured for the specified element, then an exception is thrown. Geospatial lexicons are implemented using geospatial indexes; consequently this function requires a geospatial index for the element/attribute combination specified in the function. If there is not a geospatial index configured for the specified element/attribute combination, then an exception is thrown.

Parameters:
$element-name-1 : An element QName.
$geo-element-name : An element QName.
$child-name-1 : An element or attribute QName or empty sequence. The empty sequence specifies an element geospatial lexicon.
$child-name-2 : An element or attribute QName or empty sequence. The empty sequence specifies either an element lexicon or an element-child geospatial lexicon.
$options (optional): Options. The default is ().

Options include:

"geospatial-format=format"
Use the kind of geospatial lexicon specified by format (element, element-child, element-pair, or element-attribute-pair). If neither of the child QNames is specified, the default is "element"; if only the first of the child QNames is specified, the default is "element-child:; if both child QNames are specified, the default is "element-pair". If the selection is not compatible with the number of geospatial QNames specified, an error is raised.
"ascending"
Co-occurrences should be returned in ascending order.
"descending"
Co-occurrences should be returned in descending order.
"any"
Co-occurrences from any fragment should be included.
"document"
Co-occurrences from document fragments should be included.
"properties"
Co-occurrences from properties fragments should be included.
"locks"
Co-occurrences from locks fragments should be included.
"frequency-order"
Co-occurrences should be returned ordered by frequency.
"item-order"
Co-occurrences should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included co-occurrences. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included co-occurrence. This option is used with cts:frequency.
"type=type"
For the non-geospatial lexicon, use the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"type-2=type"
For the geospatial lexicon, use the type specified by type-2 (point or long-lat-point)
"collation=URI"
For the non-geospatial lexicon, use the collation specified by URI.
"coordinate-system=URI"
For the geospatial lexicons, use the coordinate system specified by name.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"ordered"
Include co-occurrences only when the value from the first lexicon appears before the value from the second lexicon. Requires that word positions be enabled for both lexicons.
"reversed"
Consider the second lexicon as the first and vice versa.
"proximity=N"
Include co-occurrences only when the values appear within N words of each other. Requires that word positions be enabled for both lexicons.
"sample=N"
Return only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include co-occurrences in fragments selected by the cts:query. The co-occurrences do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included co-occurrences are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then co-occurrences from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, co-occurrences from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see co-occurrences from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 


cts:element-value-match(
$element-names as xs:QName*,
$pattern as xs:anyAtomicType,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element value lexicon(s) that match the specified wildcard pattern. Element value lexicons are implemented using range indexes; consequently this function requires an element range index for each element specified in the function. If there is not a range index configured for each of the specified elements, then an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$pattern : A pattern to match. The parameter type must match the lexicon type. String parameters may include wildcard characters.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"type=type"
Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
Use the range index with the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"sample=N"
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a range index with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:element-value-match(xs:QName("animal"),"aardvark*")
  => ("aardvark","aardvarks")

cts:element-value-query(
$element-name as xs:QName*,
$text as xs:string*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-value-query
Summary:

Returns a query matching elements by name with text content equal a given phrase. cts:element-value-query only matches against simple elements (that is, elements that contain only text and have no element children).

Parameters:
$element-name : One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$text : One or more element values to match. When multiple strings are specified, the query matches if any string matches.
$options (optional): Options to this query. The default is ().

Options include:

"case-sensitive"
A case-sensitive query.
"case-insensitive"
A case-insensitive query.
"diacritic-sensitive"
A diacritic-sensitive query.
"diacritic-insensitive"
A diacritic-insensitive query.
"punctuation-sensitive"
A punctuation-sensitive query.
"punctuation-insensitive"
A punctuation-insensitive query.
"whitespace-sensitive"
A whitespace-sensitive query.
"whitespace-insensitive"
A whitespace-insensitive query.
"stemmed"
A stemmed query.
"unstemmed"
An unstemmed query.
"wildcarded"
A wildcarded query.
"unwildcarded"
An unwildcarded query.
"exact"
An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded".
"lang=iso639code"
Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

If neither "case-sensitive" nor "case-insensitive" is present, $text is used to determine case sensitivity. If $text contains no uppercase, it specifies "case-insensitive". If $text contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $text is used to determine diacritic sensitivity. If $text contains no diacritics, it specifies "diacritic-insensitive". If $text contains diacritics, it specifies "diacritic-sensitive".

If neither "punctuation-sensitive" nor "punctuation-insensitive" is present, $text is used to determine punctuation sensitivity. If $text contains no punctuation, it specifies "punctuation-insensitive". If $text contains punctuation, it specifies "punctuation-sensitive".

If neither "whitespace-sensitive" nor "whitespace-insensitive" is present, the query is "whitespace-insensitive".

If neither "stemmed" nor "unstemmed" is present, the database configuration determines stemming. If the database has "stemmed searches" enabled, it specifies "stemmed". Otherwise it specifies "unstemmed".

If neither "wildcarded" nor "unwildcarded" is present, the database configuration and $text determine wildcarding. If the database has any wildcard indexes enabled ("three character searches", "two character searches", "one character searches", or "trailing wildcard searches") and if $text contains either of the wildcard characters '?' or '*', it specifies "wildcarded". Otherwise it specifies "unwildcarded".

If neither "stemmed" nor "unstemmed" is present, then the database configuration determines if a query is run as "stemmed" (stemmed searches enabled) or "unstemmed" (word searches enabled and stemmed searches disabled). If the query is a wildcard query and is also a phrase query (contains two or more terms), then any wildcard terms in the query will be "unstemmed".

Note that the text content for the value in a cts:element-value-query is treated the same as a phrase in a cts:word-query, where the phrase is the element value. Therefore, any wildcard and/or stemming rules are treated like a phrase. For example, if you have an element value of "hello friend" with wildcarding enabled for a query, a cts:element-value-query for "he*" will not match because the wildcard matches do not span word boundaries, but a cts:element-value-query for "hello *" will match. A search for "*" will match, because a "*" wildcard by itself is defined to match the value. Similarly, stemming rules are applied to each term, so a search for "hello friends" would match when stemming is enabled for the query because "friends" matches "friend". For an example, see the fourth example below.


Example:
  cts:search(//module,
    cts:element-value-query(
      xs:QName("function"), 
      "Mark Logic Corporation"))
  
=> .. relevance-ordered sequence of 'module' element ancestors of 'function' elements whose text content equals 'Mark Logic Corporation'.
Example:
  cts:search(//module,
    cts:element-value-query(
      xs:QName("function"), 
      "Mark Logic Corporation", "case-insensitive"))
  
=> .. relevance-ordered sequence of 'module' element ancestors of 'function' elements whose text content equals 'Mark Logic Corporation', or any other case-shift like 'MARK LoGic Corporation'.
Example:
  cts:search(//module,
    cts:and-query((
      cts:element-value-query(
        xs:QName("function"), 
        "Mark Logic Corporation",
        "punctuation-insensitive", 0.5),
      cts:element-value-query(
        xs:QName("title"),
        "Word Query"))))
  => .. relevance-ordered sequence of 'module' elements
  which are ancestors of both:
  (a) 'function' elements with text content equal to
      'Mark Logic Corporation', ignoring embedded 
      punctuation,
  AND
  (b) 'title' elements with text content equal to 
      'Word Query', with the results of the first sub-query
      query given weight 0.5, and the results of the second
      sub-query given the default weight 1.0.  As a result,
      the title phrase 'Word Query' counts more heavily
      towards the relevance score.
Example:
let $node := <my-node>hello friend</my-node>
return (
cts:contains($node, cts:element-value-query(xs:QName('my-node'), 
      "hello friends", "stemmed")),
cts:contains($node, cts:element-value-query(xs:QName('my-node'), 
      "he*", "wildcarded")),
cts:contains($node, cts:element-value-query(xs:QName('my-node'), 
      "hello f*", "wildcarded"))
)

=> true
   false
   true

cts:element-value-query-element-name(
$query as cts:element-value-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-value-query(
              xs:QName("function"),
              "Mark Logic Corporation")
return cts:element-value-query-element-name($query)

  => xs:QName("function")

cts:element-value-query-options(
$query as cts:element-value-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:element-value-query-options($query)
  => ("case-sensitive", "punctuation-insensitive")

cts:element-value-query-text(
$query as cts:element-value-query
)  as  xs:string*
Summary:

Returns the text used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-value-query-text($query)
  => "choice of law"

cts:element-value-query-weight(
$query as cts:element-value-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:element-value-query-weight($query)
  => 1

cts:element-value-ranges(
$element-names as xs:QName*,
[$bounds as xs:anyAtomicType*],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:range)*
Summary:

Returns value ranges from the specified element value lexicon(s). Value lexicons are implemented using range indexes; consequently this function requires an element range index for each element specified in the function. If there is not a range index configured for each of the specified elements, an exception is thrown.

The values are divided into buckets. The $bounds parameter specifies the number of buckets and the size of each bucket. All included values are bucketed, even those less than the lowest bound or greater than the highest bound. An empty sequence for $bounds specifies one bucket, a single value specifies two buckets, two values specify three buckets, and so on.

If you have string values and you pass a $bounds parameter as in the following call:

cts:element-value-ranges(xs:QName("myElement"), ("f", "m"))

The first bucket contains string values that are less than the string f, the second bucket contains string values greater than or equal to f but less than m, and the third bucket contains string values that are greater than or equal to m.

For each non-empty bucket, a cts:range element is returned. Each cts:range element has a cts:minimum child and a cts:maximum child. If a bucket is bounded, its cts:range element will also have a cts:lower-bound child if it is bounded from below, and a cts:upper-bound element if it is bounded from above. Empty buckets return nothing unless the "empties" option is specified.


Parameters:
$element-names : One or more element QNames.
$bounds (optional): A sequence of range bounds. The types must match the lexicon type. The values must be in strictly ascending order, otherwise an exception is thrown.
$options (optional): Options. The default is ().

Options include:

"ascending"
Ranges should be returned in ascending order.
"descending"
Ranges should be returned in descending order.
"empties"
Include fully-bounded ranges whose frequency is 0. These ranges will have no minimum or maximum value. Only empty ranges that have both their upper and lower bounds specified in the $bounds options are returned; any empty ranges that are less than the first bound or greater than the last bound are not returned. For example, if you specify 4 bounds and there are no results for any of the bounds, 3 elements are returned (not 5 elements).
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Ranges should be returned ordered by frequency.
"item-order"
Ranges should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"type=type"
Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
Use the lexicon with the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"sample=N"
Return only ranges for buckets with at least one value from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then ranges with all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  (: this query has the database fragmented on SPEECH and 
     finds four ranges of SPEAKERs :)
  cts:element-value-ranges(xs:QName("SPEAKER"),("F","N","S"));
  => 
  <cts:range xmlns:cts="http://marklogic.com/cts" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <cts:minimum xsi:type="xs:string">All</cts:minimum>
    <cts:maximum xsi:type="xs:string">Danes</cts:maximum>
    <cts:upper-bound xsi:type="xs:string">F</cts:maximum>
  </cts:range>
  <cts:range xmlns:cts="http://marklogic.com/cts" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <cts:minimum xsi:type="xs:string">First Ambassador</cts:minimum>
    <cts:maximum xsi:type="xs:string">Messenger</cts:maximum>
    <cts:lower-bound xsi:type="xs:string">F</cts:maximum>
    <cts:upper-bound xsi:type="xs:string">N</cts:maximum>
  </cts:range>
  <cts:range xmlns:cts="http://marklogic.com/cts" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <cts:minimum xsi:type="xs:string">OPHELIA</cts:minimum>
    <cts:maximum xsi:type="xs:string">ROSENCRANTZ</cts:maximum>
    <cts:lower-bound xsi:type="xs:string">N</cts:maximum>
    <cts:upper-bound xsi:type="xs:string">S</cts:maximum>
  </cts:range>
  <cts:range xmlns:cts="http://marklogic.com/cts" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <cts:minimum xsi:type="xs:string">Second Clown</cts:minimum>
    <cts:maximum xsi:type="xs:string">VOLTIMAND</cts:maximum>
    <cts:lower-bound xsi:type="xs:string">S</cts:maximum>
  </cts:range>

Example:
  (: this is the same query has above, but it is getting the counts
     of the number of SPEAKERs for each bucket :)
  for $bucket in cts:element-value-ranges(xs:QName("SPEAKER"),("F","N","S"))
  return cts:frequency($bucket);
  => 
  9602
  11329
  5167
  4983
  

cts:element-values(
$element-names as xs:QName*,
[$start as xs:anyAtomicType?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:anyAtomicType*
Summary:

Returns values from the specified element value lexicon(s). Value lexicons are implemented using range indexes; consequently this function requires an element range index for each element specified in the function. If there is not a range index configured for each of the specified elements, an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$start (optional): A starting value. The parameter type must match the lexicon type. If the parameter value is is not in the lexicon, then the values are returned beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
Values should be returned in ascending order.
"descending"
Values should be returned in descending order.
"any"
Values from any fragment should be included.
"document"
Values from document fragments should be included.
"properties"
Values from properties fragments should be included.
"locks"
Values from locks fragments should be included.
"frequency-order"
Values should be returned ordered by frequency.
"item-order"
Values should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included value. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included value. This option is used with cts:frequency.
"type=type"
Use the lexicon with the type specified by type (int, unsignedInt, long, unsignedLong, float, double, decimal, dateTime, time, date, gYearMonth, gYear, gMonth, gDay, yearMonthDuration, dayTimeDuration, string, or anyURI)
"collation=URI"
Use the lexicon with the collation specified by URI.
"timezone=TZ"
Return timezone sensitive values (dateTime, time, date, gYearMonth, gYear, gMonth, and gDay) adjusted to the timezone specified by TZ. Example timezones: Z, -08:00, +01:00.
"sample=N"
Return only values occurring in the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, but any analytics calculations (using cts:frequency, for example) use all the lexicon values, not just the ones constrained by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only values from the first N fragments selected by the cts:query; only values in fragments satisfying the cts:query are returned, and only those values are used in calculating any analytics (using cts:frequency, for example). Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include values in fragments selected by the cts:query. The values do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included values are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then values from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, values from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see values from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:element-values(xs:QName("animal"),"aardvark")
  => ("aardvark","aardvarks","aardwolf",...)

cts:element-word-match(
$element-names as xs:QName*,
$pattern as xs:string,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the specified element word lexicon(s) that match a wildcard pattern. This function requires an element word lexicon configured for each of the specified elements in the function. If there is not an element word lexicon configured for any of the specified elements, an exception is thrown.

Parameters:
$element-names : One or more element QNames.
$pattern : Wildcard pattern to match.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Only words that can be matched with element-word-query are included. That is, only words present in immediate text node children of the specified element as well as any text node children of child elements defined in the Admin Interface as element-word-query-throughs or phrase-throughs.


Example:
  cts:element-word-match(xs:QName("animal"),"aardvark*")
  => ("aardvark","aardvarks")

cts:element-word-query(
$element-name as xs:QName*,
$text as xs:string*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:element-word-query
Summary:

Returns a query matching elements by name with text content containing a given phrase. Searches only through immediate text node children of the specified element as well as any text node children of child elements defined in the Admin Interface as element-word-query-throughs or phrase-throughs; does not search through any other children of the specified element.

Parameters:
$element-name : One or more element QNames to match. When multiple QNames are specified, the query matches if any QName matches.
$text : Some words or phrases to match. When multiple strings are specified, the query matches if any string matches.
$options (optional): Options to this query. The default is ().

Options include:

"case-sensitive"
A case-sensitive query.
"case-insensitive"
A case-insensitive query.
"diacritic-sensitive"
A diacritic-sensitive query.
"diacritic-insensitive"
A diacritic-insensitive query.
"punctuation-sensitive"
A punctuation-sensitive query.
"punctuation-insensitive"
A punctuation-insensitive query.
"whitespace-sensitive"
A whitespace-sensitive query.
"whitespace-insensitive"
A whitespace-insensitive query.
"stemmed"
A stemmed query.
"unstemmed"
An unstemmed query.
"wildcarded"
A wildcarded query.
"unwildcarded"
An unwildcarded query.
"exact"
An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded".
"lang=iso639code"
Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

If neither "case-sensitive" nor "case-insensitive" is present, $text is used to determine case sensitivity. If $text contains no uppercase, it specifies "case-insensitive". If $text contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $text is used to determine diacritic sensitivity. If $text contains no diacritics, it specifies "diacritic-insensitive". If $text contains diacritics, it specifies "diacritic-sensitive".

If neither "punctuation-sensitive" nor "punctuation-insensitive" is present, $text is used to determine punctuation sensitivity. If $text contains no punctuation, it specifies "punctuation-insensitive". If $text contains punctuation, it specifies "punctuation-sensitive".

If neither "whitespace-sensitive" nor "whitespace-insensitive" is present, the query is "whitespace-insensitive".

If neither "stemmed" nor "unstemmed" is present, the database configuration determines stemming. If the database has "stemmed searches" enabled, it specifies "stemmed". Otherwise it specifies "unstemmed".

If neither "wildcarded" nor "unwildcarded" is present, the database configuration and $text determine wildcarding. If the database has any wildcard indexes enabled ("three character searches", "two character searches", "one character searches", or "trailing wildcard searches") and if $text contains either of the wildcard characters '?' or '*', it specifies "wildcarded". Otherwise it specifies "unwildcarded".

If neither "stemmed" nor "unstemmed" is present, then the database configuration determines if a query is run as "stemmed" (stemmed searches enabled) or "unstemmed" (word searches enabled and stemmed searches disabled). If the query is a wildcard query and is also a phrase query (contains two or more terms), then any wildcard terms in the query will be "unstemmed".


Example:
  cts:search(//module,
    cts:element-word-query(
      xs:QName("function"), 
      "Mark Logic Corporation"))
  
=> .. relevance-ordered sequence of 'module' elements ancestors (or self) of elements with QName 'function' and text content containing the phrase 'Mark Logic Corporation'.
Example:
  cts:search(//module,
    cts:element-word-query(
      xs:QName("function"), 
        "Mark Logic Corporation", "case-sensitive"))
  
=> .. relevance-ordered sequence of 'module' elements ancestors (or self) of elements with QName 'function' and text content containing the phrase 'Mark Logic Corporation', or any other case-shift, like 'Mark Logic Corporation'.
Example:
  cts:search(//module,
    cts:and-query((
      cts:element-word-query(
        xs:QName("function"), 
        "Mark Logic Corporation",
        ("case-insensitive", "punctuation-insensitive"), 0.5),
      cts:element-word-query(
        xs:QName("title"), 
        "faster"))))
  
=> .. relevance-ordered sequence of 'module' element ancestors (or self) of both: (a) 'function' elements with text content containing the phrase 'Mark Logic Corporation', ignoring embedded punctuation, AND (b) 'title' elements containing the word 'faster', with the results of the first sub-query query given weight 0.5, and the results of the second sub-query given the default weight 1.0. As a result, the title term 'faster' counts more towards the relevance score.

cts:element-word-query-element-name(
$query as cts:element-word-query
)  as  xs:QName*
Summary:

Returns the QNames used to construct the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:element-word-query(
              xs:QName("function"),
              "Mark Logic Corporation")
return cts:element-word-query-element-name($query)

  => xs:QName("function")

cts:element-word-query-options(
$query as cts:element-word-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:element-word-query-options($query)
  => ("case-sensitive", "punctuation-insensitive")

cts:element-word-query-text(
$query as cts:element-word-query
)  as  xs:string*
Summary:

Returns the text used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:element-word-query-text($query)
  => "choice of law"

cts:element-word-query-weight(
$query as cts:element-word-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:element-word-query-weight($query)
  => 1

cts:element-words(
$element-names as xs:QName*,
[$start as xs:string?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the specified element word lexicon. This function requires an element word lexicon for each of the element specified in the function. If there is not an element word lexicon configured for any of the specified elements, an exception is thrown. The words are returned in collation order.

Parameters:
$element-names : One or more element QNames.
$start (optional): A starting word. Returns only this word and any following words from the lexicon. If the parameter is not in the lexicon, then it returns the words beginning with the next word.
$options (optional): Options. The default is ().

Options include:

"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Only words that can be matched with element-word-query are included. That is, only words present in immediate text node children of the specified element as well as any text node children of child elements defined in the Admin Interface as element-word-query-throughs or phrase-throughs.


Example:
  cts:element-words(xs:QName("animal"),"aardvark")
  => ("aardvark","aardvarks","aardwolf",...)

cts:entity-highlight(
$node as node(),
$expr as item()*
)  as  node()
Summary:

Returns a copy of the node, replacing any entities found with the specified expression. You can use this function to easily highlight any entities in an XML document in an arbitrary manner. If you do not need fine-grained control of the XML markup returned, you can use the entity:enrich XQuery module function instead. A valid entity enrichment license key is required to use cts:entity-highlight; without a valid license key, it throws an exception. If you have a valid license for entity enrichment, you can entity enrich text in English and in any other languages for which you have a valid license key. For languages in which you do not have a valid license key, cts:entity-highlight finds no entities for text in that language.

Parameters:
$node : A node to run entity highlight on. The node must be either a document node or an element node; it cannot be a text node.
$expr : An expression with which to replace each match. You can use the variables $cts:text, $cts:node, $cts:entity-type and $cts:normalized-text (described below) in the expression.

Usage Notes:

There are three built-in variables to represent an entity match. These variables can be used inline in the the expression parameter.

$cts:text as xs:string
the matched entity
$cts:node as text()
the node containing the matched entity
$cts:entity-type as xs:string
the type of the matching entity
$cts:normalized-text as xs:string
the normalized entity text (only applicable for some languages)

The following are the entity types returned from the $cts:entity-type built-in variable (in alphabetical order):

FACILITY
A place used as a facility.
GPE
Geo-political entity. Differs from location because it has a person-made aspect to it (for example, California is a GPE because its boundaries were defined by a government).
IDENTIFIER:CREDIT_CARD_NUM
A number identifying a credit card number.
IDENTIFIER:DISTANCE
A number identifying a distance.
IDENTIFIER:EMAIL
Identifies an email address.
IDENTIFIER:LATITUDE_LONGITUDE
Latitude and longitude coordinates.
IDENTIFIER:MONEY
Identifies currency (dollars, euros, and so on).
IDENTIFIER:PERSONAL_ID_NUM
A number identifying a social security number or other ID number.
IDENTIFIER:PHONE_NUMBER
A number identifying a telephone number.
IDENTIFIER:URL
Identifies a web site address (URL).
IDENTIFIER:UTM
Identifies Universal Transverse Mercator coordinates.
LOCATION
A geographic location (Mount Everest, for example).
NATIONALITY
The nationality of someone or something (for example, American).
ORGANIZATION
An organization.
PERSON
A person.
RELIGION
A religion.
TEMPORAL:DATE
Date-related.
TEMPORAL:TIME
Time-related.
TITLE
Appellation or honorific associated with a person.
URL
A URL on the world wide web.
UTM
A point in the Universal Transverse Mercator (UTM) coordinate system.

Example:
let $myxml := <node>George Washington never visited Norway.  
              If he had a Social Security number, 
              it might be 000-00-0001.</node>
return
cts:entity-highlight($myxml, 
   element { fn:replace($cts:entity-type, ":", "-") } { $cts:text })

=> 
<node>
  <PERSON>George Washington</PERSON> never visited <GPE>Norway</GPE>.  
  If he had a Social Security number, it might be 
  <IDENTIFIER-PERSONAL_ID_NUM>000-00-0001</IDENTIFIER-PERSONAL_ID_NUM>.
</node>


cts:field-word-match(
$field-names as xs:string*,
$pattern as xs:string,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the specified field word lexicon(s) that match a wildcard pattern. This function requires an field word lexicon configured for each of the specified fields in the function. If there is not an field word lexicon configured for any of the specified fields, an exception is thrown.

Parameters:
$field-names : One or more field names.
$pattern : Wildcard pattern to match.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Only words that can be matched with field-word-query are included. That is, only words present in immediate text node children of the specified field as well as any text node children of child fields defined in the Admin Interface as field-word-query-throughs or phrase-throughs.


Example:
  cts:field-word-match("animal","aardvark*")
  => ("aardvark","aardvarks")

cts:field-word-query(
$field-name as xs:string*,
$text as xs:string*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:field-word-query
Summary:

Returns a query matching text content containing a given phrase in the specified field. If the specified field does not exist, cts:field-word-query throws an exception. A field is a named object that specified elements to include and exclude from a search, and can include score weights for any included elements. You create fields at the database level using the Admin Interface. For details on fields, see the chapter on "Fields Database Settings" in the Administrator's Guide.

Parameters:
$field-name : One or more field names to search over. If multiple field names are supplied, the match can be in any of the specified fields (or-query semantics).
$text : The word or phrase to match. If multiple strings are specified, the query matches if any of the words or phrases match (or-query semantics).
$options (optional): Options to this query. The default is ().

Options include:

"case-sensitive"
A case-sensitive query.
"case-insensitive"
A case-insensitive query.
"diacritic-sensitive"
A diacritic-sensitive query.
"diacritic-insensitive"
A diacritic-insensitive query.
"punctuation-sensitive"
A punctuation-sensitive query.
"punctuation-insensitive"
A punctuation-insensitive query.
"whitespace-sensitive"
A whitespace-sensitive query.
"whitespace-insensitive"
A whitespace-insensitive query.
"stemmed"
A stemmed query.
"unstemmed"
An unstemmed query.
"wildcarded"
A wildcarded query.
"unwildcarded"
An unwildcarded query.
"exact"
An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded".
"lang=iso639code"
Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

If you use cts:near-query with cts:field-word-query, the distance supplied in the near query applies to the whole document, not just to the field. For example, if you specify a near query with a distance of 3, it will return matches when the words or phrases are within 3 words in the whole document, even if some of those words are not in the specified field. For a code example illustrating this, see the second example below.

Phrases are determined based on words being next to each other (word positions with a distance of 1) and words being in the same instance of the field. Because field word positions are determined based on the fragment, not on the field, field phrases cannot span excluded elements (this is because MarkLogic Server breaks out of the field when it encounters the excluded element and start a new field when it encounters the next included element). Similarly, field phrases will not span included sibling elements. The second code example below illustrates this.

Field phrases will automatically phrase-through all child elements of an included element, until it encounters an explicitly excluded element. The third example below illustrates this. An example of when this automatic phrase-through behavior might be convenient is if you create a field that includes only the element ABSTRACT. Then all child elements of ABSTRACT are included in the field, and phrases would span all of the child elements (that is, phrases would "phrase-through" all the child elements).


Example:
cts:search(fn:doc(), cts:field-word-query("myField", "my phrase"))

=> a list of documents that contain the phrase
   "my phrase" in the field "myField". The field
   must exist in the database against which this query
   is evaluated.
Example:
(: 
   Assume the database has a field named 
   "buzz" with the element "buzz"
   included and the element "baz" excluded. 
:)
let $x := 
<hello>word1 word2 word3
  <buzz>word4 word5</buzz>
  <baz>word6 word7 word8</baz>
  <buzz>word9 word10</buzz>
</hello>
return (
cts:contains($x, cts:near-query(
  (cts:field-word-query("buzz", "word5"), 
   cts:field-word-query("buzz", "word9")), 3)),
cts:contains($x, cts:near-query(
  (cts:field-word-query("buzz", "word5"), 
   cts:field-word-query("buzz", "word9")), 4)),
cts:contains($x, 
  cts:field-word-query("buzz", "word5 word9")))
(: 
   Returns the sequence ("false", "true", "false").
   The first part does not match because 
   the distance between "word5" and "word9" 
   is 4.  This is because the distance is 
   calculated based on the whole node (if the
   document was in a database, based on the 
   fragment), not based on the field. The 
   second part specifies a distance of 4, and 
   therefore matches and returns true. The third 
   part does not match because the phrase is 
   based on the entire node, not on the field, 
   and there are words between "word5" and "word9" 
   in the node (even though not in the field).
:)

Example:
(: 
   Assume the database has a field named 
   "buzz" with the element "buzz"
   included and the element "baz" excluded. 
:)
let $x := 
<hello>
  <buzz>word1 word2
    <gads>word3 word4 word5</gads>
    <zukes>word6 word7 word8</zukes>
  word9 word10
  </buzz>
</hello>
return (
cts:contains($x, 
  cts:field-word-query("buzz", "word2 word3")))
(: 
   Returns "true" because the children of
   "buzz" are not excluded, and are therefore
   automatically phrased through.
:)


cts:field-word-query-field-name(
$query as cts:field-word-query
)  as  xs:string*
Summary:

Returns the names used to construct the specified cts:field-word-query.

Parameters:
$query : A query.

Example:
let $query := cts:field-word-query(
                "function",
                "Mark Logic Corporation")
return 
cts:field-word-query-element-name($query)

  => "function"

cts:field-word-query-options(
$query as cts:field-word-query
)  as  xs:string*
Summary:

Returns the options for the specified cts:field-word-query.

Parameters:
$query : A query.

Example:
let $query := cts:field-word-query("myField",
      "to be or not to be",
      ("case-sensitive", "punctuation-insensitive"))
return
cts:field-word-query-options($query)
  => ("case-sensitive", "punctuation-insensitive", "lang=en")

cts:field-word-query-text(
$query as cts:field-word-query
)  as  xs:string*
Summary:

Returns the text used to construct the specified cts:field-word-query.

Parameters:
$query : A query.

Example:
let $query := cts:field-word-query("myField", "choice of law")
return
cts:field-word-query-text($query)

=> "choice of law"

cts:field-word-query-weight(
$query as cts:field-word-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:field-word-query-weight($query)
  => 1

cts:field-words(
$field-names as xs:string*,
[$start as xs:string?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the specified field word lexicon. This function requires an field lexicon for each of the field specified in the function. If there is not an field word lexicon configured for any of the specified fields, an exception is thrown. The words are returned in collation order.

Parameters:
$field-names : One or more field names.
$start (optional): A starting word. Returns only this word and any following words from the lexicon. If the parameter is not in the lexicon, then it returns the words beginning with the next word.
$options (optional): Options. The default is ().

Options include:

"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Only words that can be matched with field-word-query are included. That is, only words present in immediate text node children of the specified field as well as any text node children of child fields defined in the Admin Interface as field-word-query-throughs or phrase-throughs.


Example:
  cts:field-words("animal","aardvark")
  => ("aardvark","aardvarks","aardwolf",...)

cts:fitness(
[$node as node()]
)  as  xs:float
Summary:

Returns the fitness of a node, or of the context node if no node is provided. Fitness is a normalized measure of relevance that is based on how well a node matches the query issued, not taking into account the number of documents in which the query term(s) occur.

Parameters:
$node (optional): A node. Typically this is an item in the result sequence of a cts:search operation.

Usage Notes:

Fitness is similar to score, except that it is bounded. It is similar to confidence, except that it is not influenced by term IDFs. It is an xs:float in the range of 0.0 to 1.0. It does not include quality.


Example:
  let $x := cts:search(collection(), "dog")
  return
  cts:fitness($x[1])

   => Returns the fitness value for the first item
      in the search.

cts:frequency(
$value as item()
)  as  xs:integer
Summary:

Returns an integer representing the number of times in which a particular value occurs in a value lexicon lookup (for example, cts:element-values). When using the fragment-frequency lexicon option, cts:frequency returns the number of fragments in which the lexicon value occurs. When using the item-frequency lexicon option, cts:frequency returns the total number of times in which the lexicon value occurs in each item.

Parameters:
$value : A value from a value lexicon lookup. The value should be one returned from the cts:element-values, cts:element-attribute-values, or the corresponding value-match lexicon APIs.

Usage Notes:

You must have a Range index configured to use the value lexicon APIs (cts:element-values, cts:element-value-match, cts:element-attribute-values, or cts:element-attribute-value-match).

If the value specified is not from a value lexicon lookup, cts:frequency returns a frequency of 0.

The frequency returned from cts:frequency is fragment-based by default (using the default fragment-frequency option in the lexicon API). If there are multiple occurences of the value in any given fragment, the frequency is still one per fragment when using fragment-frequency. Therefore, if the value returned is 13, it means that the value occurs in 13 fragments.

If you want the total frequency instead of the fragment-based frequency (that is, the total number of occurences of the value in the items specified in the cts:query option of the lexicon API), you must specify the item-frequency option to the lexicon API value input to cts:frequency. For example, the second example below specifies an item-frequency and a cts:document-query in the lexicon API, so the item frequency is how many times each speaker speaks in the play (because the constraining query is a document query of hamlet.xml, which contains the whole play).


Example:
<results>{
let $x := cts:element-values(xs:QName("SPEAKER"),"",(), 
  cts:document-query("/shakespeare/plays/hamlet.xml"))
for $speaker in $x
return 
(
<result>
  <SPEAKER>{$speaker}</SPEAKER> 
  <NUMBER-OF-SPEECHES>{cts:frequency($speaker)}</NUMBER-OF-SPEECHES> 
</result>
)
}</results>

=> Returns the names of the speakers in Hamlet
   with the number of times they speak. If the
   play is fragmented at the SCENE level, then 
   it returns the number of scenes in which each 
   speaker speaks. 
Example:
<results>{
let $x := cts:element-values(xs:QName("SPEAKER"),
  "", "item-frequency", 
  cts:document-query("/shakespeare/plays/hamlet.xml"))
for $speaker in $x
return 
(
<result>
  <SPEAKER>{$speaker}</SPEAKER> 
  <NUMBER-OF-SPEECHES>
    {cts:frequency($speaker)}
  </NUMBER-OF-SPEECHES> 
</result>
)
}</results>

=> Returns the names of the speakers in Hamlet
   with the number of times they speak. Returns
   the total times they speak, regardless
   of fragmentation. 

cts:geospatial-co-occurrences(
$geo-element-name-1 as xs:QName,
$child-1-name-1 as xs:QName?,
$child-1-name-2 as xs:QName?,
$geo-element-name-2 as xs:QName,
$child-2-name-1 as xs:QName?,
$child-2-name-2 as xs:QName?,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  element(cts:co-occurrence)*
Summary:

Returns value co-occurrences from the geospatial lexicons. Geospatial lexicons are implemented using geospatial indexes; consequently this function requires a geospatial index for each combination of elements and attributes specified in the function. If there is not a geospatial index configured for the specified element/attribute combination, then an exception is thrown.

Parameters:
$geo-element-name-1 : An element QName.
$child-1-name-1 : An element or attribute QName or empty sequence. The empty sequence specifies an element geospatial lexicon.
$child-1-name-2 : An element or attribute QName or empty sequence. The empty sequence specifies either an element lexicon or an element-child geospatial lexicon.
$geo-element-name-2 : An element QName.
$child-2-name-1 : An element or attribute QName or empty sequence. The empty sequence specifies an element geospatial lexicon.
$child-2-name-2 : An element or attribute QName or empty sequence. The empty sequence specifies either an element lexicon or an element-child geospatial lexicon.
$options (optional): Options. The default is ().

Options include:

"geospatial-format=format"
For both geospatial lexicons, use the kind of geospatial lexicon specified by format (element, element-child, element-pair, or element-attribute-pair). If neither of the child QNames is specified, the default is "element"; if only the first of the child QNames is specified, the default is "element-child:; if both child QNames are specified, the default is "element-pair". If the selection is not compatible with the number of geospatial QNames specified, an error is raised.
"geospatial-format-1=format"
For the first geospatial lexicon, use the kind of geospatial lexicon specified by format (element, element-child, element-pair, or element-attribute-pair). If neither of the child QNames is specified, the default is "element"; if only the first of the child QNames is specified, the default is "element-child:; if both child QNames are specified, the default is "element-pair". If the selection is not compatible with the number of geospatial QNames specified, an error is raised.
"geospatial-format-2=format"
For the second geospatial lexicons, use the kind of geospatial lexicon specified by format (element, element-child, element-pair, or element-attribute-pair). If neither of the child QNames is specified, the default is "element"; if only the first of the child QNames is specified, the default is "element-child:; if both child QNames are specified, the default is "element-pair". If the selection is not compatible with the number of geospatial QNames specified, an error is raised.
"ascending"
Co-occurrences should be returned in ascending order.
"descending"
Co-occurrences should be returned in descending order.
"any"
Co-occurrences from any fragment should be included.
"document"
Co-occurrences from document fragments should be included.
"properties"
Co-occurrences from properties fragments should be included.
"locks"
Co-occurrences from locks fragments should be included.
"frequency-order"
Co-occurrences should be returned ordered by frequency.
"item-order"
Co-occurrences should be returned ordered by item.
"fragment-frequency"
Frequency should be the number of fragments with an included co-occurrences. This option is used with cts:frequency.
"item-frequency"
Frequency should be the number of occurences of an included co-occurrence. This option is used with cts:frequency.
"coordinate-system=URI"
For both geospatial lexicons, use the coordinate system specified by name.
"coordinate-system-1=URI"
For the first geospatial lexicon, use the coordinate system specified by name.
"coordinate-system-2=URI"
For the second geospatial lexicons, use the coordinate system specified by name.
"ordered"
Include co-occurrences only when the value from the first lexicon appears before the value from the second lexicon. Requires that word positions be enabled for both lexicons.
"reversed"
Consider the second lexicon as the first and vice versa.
"proximity=N"
Include co-occurrences only when the values appear within N words of each other. Requires that word positions be enabled for both lexicons.
"sample=N"
Return only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only co-occurrences from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include co-occurrences in fragments selected by the cts:query. The co-occurrences do not need to match the query, but they must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "fragment-frequency" or "item-frequency" may be specified in the options parameter. If neither "fragment-frequency" nor "item-frequency" is specified, then the default is "fragment-frequency".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "coordinate-system=name" is not specified in the options parameter, then the default coordinate system is used. If a lexicon with that coordinate system does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included co-occurrences are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then co-occurrences from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, co-occurrences from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see co-occurrences from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query( () ) 


cts:highlight(
$node as node(),
$query as cts:query,
$expr as item()*
)  as  node()
Summary:

Returns a copy of the node, replacing any text matching the query with the specified expression. You can use this function to easily highlight any text found in a query. Unlike fn:replace and other XQuery string functions that match literal text, cts:highlight matches every term that matches the search, including stemmed matches or matches with different capitalization.

Parameters:
$node : A node to highlight. The node must be either a document node or an element node; it cannot be a text node.
$query : A query specifying the text to highlight. If a string is entered, the string is treated as a cts:word-query of the specified string.
$expr : An expression with which to replace each match. You can use the variables $cts:text, $cts:node, and $cts:queries (described below) in the expression.

Usage Notes:

There are three built-in variables to represent a query match. These variables can be used inline in the the expression parameter.

$cts:text as xs:string
the matched text
$cts:node as text()
the node containing the matched text
$cts:queries as cts:query*
the matching queries

You cannot use cts:highlight to highlight results from cts:similar-query and cts:element-attribute-*-query items. Using cts:highlight with these queries will return the nodes without any highlighting.

You can also use cts:highlight as a general search and replace function. The specified expression will replace any matching text. For example, you could replace the word "hello" with "goodbye" in a query similar to the following:

 cts:highlight($node, "hello", "goodbye")

Because the expressions can be any XQuery expression, they can be very simple like the above example or they can be extremely complex.


Example:
To highlight "MarkLogic" with bold in the following paragraph:
  
let $x :=  <p>MarkLogic Server is an enterprise-class 
  database specifically built for content.</p>
return 
cts:highlight($x, "MarkLogic", <b>{$cts:text}</b>)

Returns:
  
  <p><b>MarkLogic</b> Server is an enterprise-class 
  database specifically built for content.</p> 
  
Example:
Given the following document with the URI "hellogoodbye.xml":

<root>
  <a>It starts with hello and ends with goodbye.</a>
</root>

The following query will highlight the word "hello" in 
blue, and everything else in red.

cts:highlight(doc("hellogoodbye.xml"), 
       cts:and-query((cts:word-query("hello"),
                      cts:word-query("goodbye"))),
  if (cts:word-query-text($cts:queries) eq "hello")
  then (<font color="blue">{$cts:text}</font>)
  else (<font color="red">{$cts:text}</font>))
             
returns:

<root>
  <a>It starts with <font color="blue">hello</font> 
  and ends with <font color="red">goodbye</font>.</a>
</root>
Example:
for $x in cts:search(collection(), "MarkLogic")
return
cts:highlight($x, "MarkLogic", <b>{$cts:text}</b>)

returns all of the nodes that contain "MarkLogic", 
placing bold markup around the matched words.

cts:near-query(
$queries as cts:query*,
[$distance as xs:double],
[$options as xs:string*],
[$distance-weight as xs:double]
)  as  cts:near-query
Summary:

Returns a query matching all of the specified queries, where the matches occur within the specified distance from each other.

Parameters:
$queries : A sequence of queries to match.
$distance (optional): A distance, in number of words, between any two matching queries. The results match if two queries match and the distance between the two matches is equal to or less than the specified distance. A distance of 0 matches when the text is the exact same text or when there is overlapping text (see the third example below). A negative distance is treated as 0. The default value is 100.
$options (optional): Options to this query. The default value is ().

Options include:

"ordered"
Any near-query matches must occur in the order of the specified sub-queries.
"unordered"
Any near-query matches will satisfy the query, regardless of the order they were specified.
$distance-weight (optional): A weight attributed to the distance for this query. Higher weights add to the importance of distance (as opposed to term matches) when the relevance order is calculated. The default value is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score. This parameter has no effect if the word positions index is not enabled.

Usage Notes:

If the options parameter contains neither "ordered" nor "unordered", then the default is "unordered".

The word positions index will speed the performance of queries that use cts:near-query. The element word positions index will speed the performance of element-queries that use cts:near-query.

If you use cts:near-query with a field, the distance specified is the distance in the whole document, not the distance in the field. For example, if the distance between two words is 20 in the document, but the distance is 10 if you look at a view of the document that only includes the elements in a field, a cts:near-query must have a distance of 20 or more to match; a distance of 10 would not match.

If you use cts:near-query with cts:field-word-query, the distance supplied in the near query applies to the whole document, not just to the field. For details, see cts:field-word-query.

Expressions using the ordered option are more efficient than those using the unordered option, especially if they specify many queries to match.


Example:
 The following query searches for paragraphs containing 
 both "MarkLogic" and "Server" within 3 words of each 
 other, given the following paragraphs in a database:

  <p>MarkLogic Server is an enterprise-class 
  database specifically built for content.</p>
  <p>MarkLogic is an excellent XML Content Server.</p> 

  cts:search(//p,
    cts:near-query(
      (cts:word-query("MarkLogic"),
      cts:word-query("Server")),
      3))
  
  =>
  <p>MarkLogic Server is an enterprise-class 
  database specifically built for content.</p> 
      
Example:
let $x := <p>Now is the winter of our discontent</p>
return
cts:contains($x, cts:near-query(
                    ("discontent", "winter"), 
                    3, "ordered"))

=> false because "discontent" comes after "winter"

let $x := <p>Now is the winter of our discontent</p>
return
cts:contains($x, cts:near-query(
                    ("discontent", "winter"), 
                    3, "unordered"))

=> true because the query specifies "unordered",
        and it is still a match even though
        "discontent" comes after "winter"
      
Example:
let $x := <p>Now is the winter of our discontent</p>
return
cts:contains($x, cts:near-query(
                    ("is the winter", "winter of"), 
                    0))

=> true because the phrases overlap

let $x := <p>Now is the winter of our discontent</p>
return
cts:contains($x, cts:near-query(
                    ("is the winter", "of our"), 
                    0))

=> false because the phrases do not overlap
         (they have 1 word distance, not 0)
      

cts:near-query-distance(
$query as cts:near-query
)  as  xs:integer
Summary:

Returns the distance used to construct the near query.

Parameters:
$query : A query.

Example:
let $query := cts:near-query(
                 cts:word-query("wanted"), 
                 cts:word-query("unwanted"),
                 12)
return cts:near-query-distance($query)
  => 12

cts:near-query-options(
$query as cts:near-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
let $query := cts:near-query(
                 cts:word-query("wanted"), 
                 cts:word-query("unwanted"),
                 12,
                 "ordered")
return
  cts:near-query-options($query)
  => "ordered"

cts:near-query-queries(
$query as cts:near-query
)  as  cts:query
Summary:

Returns the query sequence used to construct the near query.

Parameters:
$query : A query.

Example:
  cts:near-query-queries($query)
  => ... a sequence of the queries used to 
            construct this query
Example:
let $query := 
  cts:near-query((
    cts:word-query("to be or"), 
    cts:word-query("or not to be")))
return cts:near-query-queries($query)
  => (cts:word-query("to be or", (), 1) 
         cts:word-query("or not to be", (), 1))

cts:near-query-weight(
$query as cts:near-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
let $query := cts:near-query(
                 cts:word-query("wanted"), 
                 cts:word-query("unwanted"),
                 12, "ordered", 5.0)
return
  cts:near-query-weight($query)
  => 5.0

cts:not-query(
$query as cts:query,
[$weight as xs:double]
)  as  cts:not-query
Summary:

Returns a query specifying the matches not specified by its sub-query.

Parameters:
$query : A negative query, specifying the search results to filter out.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

The cts:not-query constructor is fragment-based, so it returns true only if the specified query does not produce a match anywhere in a fragment. Therefore, a search using cts:not-query is only guaranteed to be accurate if the underlying query that is being negated is accurate from its index resolution (that is, if the unfiltered results of the $query parameter to cts:not-query are accurate). The accuracy of the index resolution depends on the many factors such as the query, if you search at a fragment root (that is, if the first parameter of cts:search specifies an XPath that resolves to a fragment root), the index options enabled on the database, the search options, and other factors. In cases where the $query parameter has false-positive matches, the negation of the query can miss matches (have false negative matches). In these cases, searches with cts:not-query can miss results, even if those searches are filtered.

Example:
  cts:search(//PLAY,
    cts:not-query(
      cts:word-query("summer")))
  => ...  sequence of 'PLAY' elements not containing 
          any text node with the word 'summer'.  
Example:
let $doc := 
  <doc>  
   <p n="1">Dogs, cats, and pigs</p>
   <p n="2">Trees, frogs, and cats</p>
   <p n="3">Dogs, alligators, and wolves</p>
  </doc> 
return
$doc//p[cts:contains(., cts:not-query("cat"))]
(: Returns the third p element (the one without
   a "cat" term). Note that the
   cts:contains forces the constraint to happen
   in the filtering stage of the query. :)


cts:not-query-query(
$query as cts:not-query
)  as  cts:query
Summary:

Returns the query used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:not-query-query($query)
  => cts:word-query("Mark Logic")

cts:not-query-weight(
$query as cts:element-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:not-query-weight($query)
  => 1

cts:or-query(
$queries as cts:query*
)  as  cts:or-query
Summary:

Returns a query specifying the union of the matches specified by the sub-queries.

Parameters:
$queries : A sequence of sub-queries.

Example:
  cts:search(//PLAY,
    cts:or-query((
      cts:word-query("summer"),
      cts:word-query("sun of York"))))
  => .. a sequence of 'PLAY' elements which are
  ancestors (or self) of some node whose text content
  contains the word 'summer' OR some node
  whose text content contains the phrase 'sun of York'.
  This union contains at least one 'PLAY' node with:

    PLAY/TITLE = 
      "The Tragedy of King Richard the Second",

  but also contains other 'PLAY' nodes containing some 
  text node with the word "summer", for example,

    PLAY/TITLE = "A Midsummer Night's Dream".

cts:or-query-queries(
$query as cts:or-query
)  as  cts:query*
Summary:

Returns a sequence of the queries that were used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:or-query-queries($query)
  => ... a sequence of the queries used to construct this query

cts:point(
$latitude as xs:float,
$longitude as xs:float
)  as  cts:point
Summary:

Returns a point value.

Parameters:
$latitude : The latitude of the point.
$longitude : The longitude of the point.

Example:
  cts:point(0.373899653086420E+02, -0.122078578406509E+03)

cts:point-latitude(
$point as cts:point
)  as  xs:float
Summary:

Returns a point's latitude value.

Parameters:
$point : The point.

Example:
  let $point := cts:point(37.270556, -118.672778)
  return
  cts:point-latitude($point)

cts:point-longitude(
$point as cts:point
)  as  xs:float
Summary:

Returns a point's longitude value.

Parameters:
$point : The point.

Example:
  let $point := cts:point(37.270556, -118.672778)
  return
  cts:point-longitude($point)

cts:polygon(
$vertices as cts:point*
)  as  cts:polygon
Summary:

Returns a geospatial polygon value.

Parameters:
$vertices : The vertices of the polygon, given in order. No edge may cover more than 180 degrees of either latitude or longitude. The polygon as a whole may not encompass both poles. These constraints are necessary to ensure an unambiguous interpretation of the polygon. There must be at least three vertices. The first vertex should be identical to the last vertex to close the polygon. vertexes.

Example:
  (: this polygon approximates the 94041 zip code :)
  let $points := (cts:point(0.373899653086420E+02, -0.122078578406509E+03),
    cts:point(0.373765400000000E+02, -0.122063772000000E+03),
    cts:point(0.373781400000000E+02, -0.122067972000000E+03),
    cts:point(0.373825650000000E+02, -0.122068365000000E+03),
    cts:point(0.373797400000000E+02, -0.122072172000000E+03),
    cts:point(0.373899400000000E+02, -0.122092573000000E+03),
    cts:point(0.373941400000000E+02, -0.122095573000000E+03),
    cts:point(0.373966400000000E+02, -0.122094173000000E+03),
    cts:point(0.373958400000000E+02, -0.122092373000000E+03),
    cts:point(0.374004400000000E+02, -0.122091273000000E+03),
    cts:point(0.374004400000000E+02, -0.122091273000000E+03),
    cts:point(0.373873400000000E+02, -0.122057872000000E+03),
    cts:point(0.373873400000000E+02, -0.122057872000000E+03),
    cts:point(0.373854400000000E+02, -0.122052672000000E+03),
    cts:point(0.373833400000000E+02, -0.122053372000000E+03),
    cts:point(0.373819400000000E+02, -0.122057572000000E+03),
    cts:point(0.373775400000000E+02, -0.122060872000000E+03),
    cts:point(0.373765400000000E+02, -0.122063772000000E+03) )
  return
  cts:polygon($points)

cts:polygon-vertices(
$polygon as cts:polygon
)  as  cts:point*
Summary:

Returns a polygon's vertices. The first vertex and last vertex will always be the same.

Parameters:
$polygon : The polygon.

Example:
  let $node := 
    <polygon zip="94041">
       0.373899653086420E+02,       -0.122078578406509E+03
       0.373765400000000E+02,       -0.122063772000000E+03
       0.373781400000000E+02,       -0.122067972000000E+03
       0.373825650000000E+02,       -0.122068365000000E+03
       0.373797400000000E+02,       -0.122072172000000E+03
       0.373899400000000E+02,       -0.122092573000000E+03
       0.373941400000000E+02,       -0.122095573000000E+03
       0.373966400000000E+02,       -0.122094173000000E+03
       0.373958400000000E+02,       -0.122092373000000E+03
       0.374004400000000E+02,       -0.122091273000000E+03
       0.374004400000000E+02,       -0.122091273000000E+03
       0.373873400000000E+02,       -0.122057872000000E+03
       0.373873400000000E+02,       -0.122057872000000E+03
       0.373854400000000E+02,       -0.122052672000000E+03
       0.373833400000000E+02,       -0.122053372000000E+03
       0.373819400000000E+02,       -0.122057572000000E+03
       0.373775400000000E+02,       -0.122060872000000E+03
       0.373765400000000E+02,       -0.122063772000000E+03
    </polygon>
    return
    cts:polygon-vertices(cts:polygon(fn:data($node)))

cts:quality(
[$node as node()]
)  as  xs:integer
Summary:

Returns the quality of a node, or of the context node if no node is provided.

Parameters:
$node (optional): A node. Typically this is an item in the result sequence of a cts:search operation.

Usage Notes:

If you run cts:quality on a constructed node, it always returns 0; it is primarily intended to run on nodes that are the retrieved from the database (an item from a cts:search result or an item from the result of an XPath expression that searches through the database).


Example:
  xdmp:document-insert("/test.xml", <a>my test</a>, (), (), 50);
  for $x in cts:search(collection(),"my test")
  return cts:quality($x) => 50
Example:
  for $a in cts:search(collection(),"my test")
  where $a[cts:quality() gt 10]
  return xdmp:node-uri($a) => /test.xml

cts:query(
[$query as element()]
)  as  cts:query
Summary:

Creates a query.

Parameters:
$query (optional): A query.

Example:
cts:query(
  <cts:word-query xmlns:cts="http://marklogic.com/cts">
    <cts:text>word</cts:text>
  </cts:word-query>
)


cts:register(
$query as cts:query
)  as  xs:unsignedLong
Summary:

Register a query for later use.

Parameters:
$query : A query to register.

Example:
  cts:register(cts:collection-query("mycollection"))
  
  => 12345678901234567

cts:registered-query(
$ids as xs:unsignedLong*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:registered-query
Summary:

Returns a query matching fragments specified by previously registered queries (see cts:register). If a registered query with the specified ID(s) is not found, then a cts:search operation with an invalid cts:registered-query throws an XDMP-UNREGISTERED exception.

Parameters:
$ids : Some registered query identifiers.
$options (optional): Options to this query. The default is ().

Options include:

"filtered"
A filtered query (the default). Filtered queries eliminate any false-positive results and properly resolve cases where there are multiple candidate matches within the same fragment, thereby guaranteeing that the results fully satisfy the original cts:query item that was registered. This option is not available in the 4.0 release.
"unfiltered"
An unfiltered query. Unfiltered registered queries select fragments from the indexes that are candidates to satisfy the cts:query. Depending on the original cts:query, the structure of the documents in the database, and the configuration of the database, unfiltered registered queries may result in false-positive results or in incorrect matches when there are multiple candidate matches within the same fragment. To avoid these problems, you should only use unfiltered queries on top-level XPath expressions (for example, document nodes, collections, directories) or on fragment roots. Using unfiltered queries on complex XPath expressions or on XPath expressions that traverse below a fragment root can result in unexpected results. This option is required in the 4.0 release.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

If the options parameter does not contain "unfiltered", then an error is returned, as the "unfiltered" option is required.

Registered queries are persisted as a soft state only; they can become unregistered through an explicit direction (using cts:deregister), as a result of the cache growing too large, or because of a server restart. Consequently, either your XQuery code or your middleware layer should handle the case when an XDMP-UNREGISTERED exception occurs (for example, you can wrap your cts:registered-query code in a try/catch block or your Java or .NET code can catch and handle the exception).


Example:
  cts:search(//function,
    cts:registered-query(1234567890123456,"unfiltered"))
  
  => .. relevance-ordered sequence of 'function' elements
  in any document that also matches the registered query
Example:
(: wrap the registered query in a try/catch :)
try {
cts:search(fn:doc(),cts:registered-query(995175721241192518,"unfiltered")))
} catch ($e) {
  if ($e/err:code = "XDMP-UNREGISTERED")
  then ("Retry this query with the following registered query ID: ",
        cts:register(cts:word-query("hello*world","wildcarded")))
  else $e
}

cts:registered-query-ids(
$query as cts:registered-query
)  as  xs:unsignedLong*
Summary:

Returns the registered query identifiers used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:registered-query-ids($query)
  => 1234567890123456

cts:registered-query-options(
$query as cts:registered-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:registered-query-options($query)
  => "unfiltered"

cts:registered-query-weight(
$query as cts:registered-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:registered-query-weight($query)
  => 1

cts:remainder(
[$node as node()]
)  as  xs:integer
Summary:

Returns an estimated search result size for a node, or of the context node if no node is provided. The search result size for a node is the number of fragments remaining (including the current node) in the result sequence containing the node. This is useful to quickly estimate the size of a search result sequence, without using fn:count() or xdmp:estimate().

Parameters:
$node (optional): A node. Typically this is an item in the result sequence of a cts:search operation. If you specify the first item from a cts:search expression, then cts:remainder will return an estimate of the number of fragments that match that expression.

Usage Notes:

This function makes it efficient to estimate the size of a search result and execute that search in the same query. If you only need an estimate of the size of a search but do not need to run the search, then xdmp:estimate is more efficient.

To return the estimated size of a search with cts:remainder, use the first item of a cts:search result sequence as the parameter to cts:remainder. For example, the following query returns the estimated number of fragments that contain the word "dog":

  cts:remainder(cts:search(collection(), "dog")[1]) 

When you put the position predicate on the cts:search result sequence, MarkLogic Server will filter all of the false-positive results up to the specified position, but not the false-positive results beyond the specified position. Because of this, when you increase the position number in the parameter, the result from cts:remainder might decrease by a larger number than the increase in position number, or it might not decrease at all. For example, if the query above returned 10, then the following query might return 9, it might return 10, or it might return less than 9, depending on how the results are dispersed throughout different fragments:

  cts:remainder(cts:search(collection(), "dog")[2]) 

If you run cts:remainder on a constructed node, it always returns 0; it is primarily intended to run on nodes that are the retrieved from the database (an item from a cts:search result or an item from the result of an XPath expression that searches through the database).


Example:
  let $x := cts:search(collection(), "dog")
  return
  (cts:remainder($x[1]), $x)

   => Returns the estimated number of items in the search 
      for "dog" followed by the results of the search.
Example:
  xdmp:document-insert("/test.xml", <a>my test</a>);
  for $x in cts:search(collection(),"my test")
  return cts:remainder($x) => 1
Example:
  for $a in cts:search(collection(),"my test")
  where $a[cts:remainder() eq 1]
  return xdmp:node-uri($a) => /test.xml

cts:reverse-query(
$nodes as node()*,
[$weight as xs:double]
)  as  cts:reverse-query
Summary:

Returns a query matching the model nodes. Use with a cts:search or a cts:contains over serialized cts:query nodes. The serialized cts:query nodes can be either stored in the database or passed in as XML.

Parameters:
$nodes : Some model nodes that contain serialized cts:query constructors.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

When performing a cts:reverse-query on a set of nodes, the cts:similar-query or cts:registered-query components of any stored query will match all nodes.

Example:
let $query := <query>{cts:word-query("hello")}</query>
let $x := <bar>hello</bar>
return
cts:contains($query, cts:reverse-query($x))
(: 
   returns true because the cts:word-query for "hello" 
   would match the document in $x
:)


cts:reverse-query-nodes(
$query as cts:reverse-query
)  as  node()*
Summary:

Returns the nodes used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:reverse-query-nodes($query)
  => //function

cts:reverse-query-weight(
$query as cts:reverse-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:similar-query-weight($query)
  => 1

cts:score(
[$node as node()]
)  as  xs:integer
Summary:

Returns the score of a node, or of the context node if no node is provided.

Parameters:
$node (optional): A node. Typically this is an item in the result sequence of a cts:search operation.

Usage Notes:

Score is computed according to the scoring method specified in the cts:search expression, if any.

If you run cts:score on a constructed node, it always returns 0; it is primarily intended to run on nodes that are the retrieved from the database (an item from a cts:search result or an item from the result of an XPath expression that searches through the database).


Example:
(: run this on the Shakespeare content set :)
for $hit in cts:search(//SPEECH,
    cts:word-query("with flowers"))[1 to 10]
return element hit {
  attribute score { cts:score($hit) },
  $hit
}
Example:
  xdmp:document-insert("/test.xml", <a>my test</a>);
  for $x in cts:search(doc("/test.xml"),"my test")
  return cts:score($x) => 11
Example:
  for $a in cts:search(collection(),"my test") 
  where $a[cts:score() gt 10]
  return xdmp:node-uri($a) => /test.xml

cts:search(
$expression as node()*,
$query as cts:query?,
[$options as xs:string*],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  node()*
Summary:

Returns a relevance-ordered sequence of nodes specified by a given query.

Parameters:
$expression : An expression to be searched. This must be an inline fully searchable path expression.
$query : A cts:query specifying the search to perform. If a string is entered, the string is treated as a cts:word-query of the specified string.
$options (optional): Options to this search. The default is ().

Options include:

"filtered"

A filtered search (the default). Filtered searches eliminate any false-positive matches and properly resolve cases where there are multiple candidate matches within the same fragment. Filtered search results fully satisfy the specified cts:query.

"unfiltered"

An unfiltered search. An unfiltered search selects fragments from the indexes that are candidates to satisfy the specified cts:query, and then it returns a single node from within each fragment that satisfies the specified searchable path expression. Unfiltered searches are useful because of the performance they afford when jumping deep into the result set (for example, when paginating a long result set and jumping to the 1,000,000th result). However, depending on the searchable path expression, the cts:query specified, the structure of the documents in the database, and the configuration of the database, unfiltered searches may yield false-positive results being included in the search results. Unfiltered searches may also result in missed matches or in incorrect matches, especially when there are multiple candidate matches within a single fragment. To avoid these problems, you should only use unfiltered searches on top-level XPath expressions (for example, document nodes, collections, directories) or on fragment roots. Using unfiltered searches on complex XPath expressions or on XPath expressions that traverse below a fragment root can result in unexpected results.

"score-logtfidf"

Compute scores using the logtfidf method (the default scoring method). This uses the formula:

  log(term frequency) * (inverse document frequency)

"score-logtf"

Compute scores using the logtf method. This does not take into account how many documents have the term and uses the formula:

  log(term frequency)

"score-simple"

Compute scores using the simple method. The score-simple method gives a score of 8*weight for each matching term in the cts:query expression. It does not matter how many times a given term matches (that is, the term frequency does not matter); each match contributes 8*weight to the score. For example, the following query (assume the default weight of 1) would give a score of 8 for any fragment with one or more matches for "hello", a score of 16 for any fragment that also has one or more matches for "goodbye", or a score of zero for fragments that have no matches for either term:

  cts:or-query(("hello", "goodbye"))

"checked"

Word positions are checked (the default) when resolving the query. Checked searches eliminate false-positive matches for phrases during the index resolution phase of search processing.

"unchecked"

Word positions are not checked when resolving the query. Unchecked searches do not take into account word positions and can lead to false-positive matches during the index resolution phase of search processing. This setting is useful for debugging, but not recommended for normal use.

$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is (). You can use cts:search with this parameter and an empty cts:and-query to specify a forest-specific XPath statement (see the third example below). If you use this to constrain an XPath to one or more forests, you should set the quality-weight to zero to keep the XPath document order.

Usage Notes:

Queries that use cts:search require that the XPath expression searched is fully searchable. A fully searchable path is one that has no steps that are unsearchable. You can use the xdmp:query-trace() function to see if the path is fully searchable. If there are no entries in the xdmp:query-trace() output indicating that a step is unsearchable, then that path is fully searchable. Queries that use cts:search on unsearchable XPath expressions will fail with an an error message. You can often make the path expressions fully searchable by rewriting the query or adding new indexes.

Each node that cts:search returns has a score with which it is associated. To access the score, use the cts:score function. The nodes are returned in relevance order (most relevant to least relevant), where more relevant nodes have a higher score.

Only one of the "filtered" or "unfiltered" options may be specified in the options parameter. If neither "filtered" nor "unfiltered", is specified then the default is "filtered".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf" are specified, or "score-simple", then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If the neither "checked" nor "unchecked" are specified, then the default is "checked".

If the cts:query specified is the empty string (equivalent to cts:word-query("")), then the search returns the empty sequence.


Example:
  cts:search(//SPEECH,
    cts:word-query("with flowers"))
  
  => ... a sequence of 'SPEECH' element ancestors (or self)
     of any node containing the phrase 'with flowers'.
Example:
  cts:search(collection("self-help")/book,
    cts:element-query(xs:QName("title"), "meditation"),
    "score-simple", 1.0, (xdmp:forest("prod"),xdmp:forest("preview")))

  => ... a sequence of book elements matching the XPath
     expression which are members of the "self-help"
     collection, reside in the the "prod" or "preview" forests and
     contain "meditation" in the title element, using the
     "score-simple" option.
Example:
  cts:search(/some/xpath, cts:and-query(()), (), 0.0,
    xdmp:forest("myForest"))

  => ... a sequence of /some/xpath elements that are
     in the forest named "myForest".  Note the 
     empty and-query, which matches all documents (and
     scores them all the same) and the quality-weight
     of 0, which together make each result have a score
     of 0, which keeps the results in document order.

cts:similar-query(
$nodes as node()*,
[$weight as xs:double]
)  as  cts:similar-query
Summary:

Returns a query matching nodes similar to the model nodes. It uses an algorithm which finds the 16 most "relevant" terms in the model nodes (that is, the 16 terms with the highest scores), and then creates a query equivalent to a cts:or-query of those 16 terms.

Parameters:
$nodes : Some model nodes.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

As the number of fragments in a database grows, the results of cts:similar-query become increasingly accurate. For best results, there should be at least 10,000 fragments for 32-bit systems, and 1,000 fragments for 64-bit systems.

Example:
  cts:search(//function,
    cts:similar-query((//function)[1]))
  
=> .. relevance-ordered sequence of 'function' element ancestors (or self) of any node similar to the first 'function' element.

cts:similar-query-nodes(
$query as cts:similar-query
)  as  node()*
Summary:

Returns the nodes used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:similar-query-nodes($query)
  => //function

cts:similar-query-weight(
$query as cts:similar-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:similar-query-weight($query)
  => 1

cts:stem(
$text as xs:string,
[$language as xs:string]
)  as  xs:string*
Summary:

Returns the stem(s) for a word.

Parameters:
$text : A word or phrase to stem.
$language (optional): A language to use for stemming. If not supplied, it uses the database default language.

Usage Notes:

In general, you should pass a word into cts:stem; if you enter a phrase, it will stem the phrase, which will normally stem to itself.

When you stem a word through cts:stem, it returns all of the stems for the word, including decompounding and multiple stems, regardless of the database stemming setting.


Example:
cts:stem("ran","en")
=> "run"

cts:tokenize(
$text as xs:string,
[$language as xs:string]
)  as  cts:token*
Summary:

Tokenizes text into words, punctuation, and spaces. Returns output in the type cts:token, which has subtypes cts:word, cts:punctuation, and cts:space, all of which are subtypes of xs:string.

Parameters:
$text : A word or phrase to tokenize.
$language (optional): A language to use for tokenization. If not supplied, it uses the database default language.

Usage Notes:

When you tokenize a string with cts:tokenize, each word is represented by an instance of cts:word, each punctuation character is represented by an instance of cts:punctuation, each set of adjacent spaces is represented by an instance of cts:space, and each set of adjacent line breaks is represented by an instance of cts:space.

Unlike the standard XQuery function fn:tokenize, cts:tokenize returns words, punctuation, and spaces as different types. You can therefore use a typeswitch to handle each type differently. For example, you can use cts:tokenize to remove all punctuation from a string, or create logic to test for the type and return different things for different types, as shown in the first two examples below.

You can use xdmp:describe to show how a given string will be tokenized. When run on the results of cts:tokenize, the xdmp:describe function returns the types and the values for each token. For a sample of this pattern, see the third example below.


Example:
(: Remove all punctuation :)
let $string := "The red, blue, green, and orange
                balloons were launched!" 
let $noPunctuation := 
  for $token in cts:tokenize($string)
  return
    typeswitch ($token)
     case $token as cts:punctuation return ""
     case $token as cts:word return $token
     case $token as cts:space return $token
     default return ()
return string-join($noPunctuation, "")
  
=> The red blue green and orange balloons were launched
Example:
(: Insert the string "XX" before and after 
   all punctuation tokens :)
let $string := "The red, blue, green, and orange
                 balloons were launched!"
let $tokens := cts:tokenize($string)
return string-join(
for $x in $tokens
return if ($x instance of cts:punctuation)
       then (concat("XX",
                     $x, "XX"))
       else ($x) , "")
 => The redXX,XX blueXX,XX greenXX,XX and orange
    balloons were launchedXX!XX
 
Example:
(: show the types and tokens for a string :)
xdmp:describe(cts:tokenize("blue, green"))

=> (cts:word("blue"), cts:punctuation(","), 
    cts:space(" "), cts:word("green"))

cts:uri-match(
$pattern as xs:string,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns values from the URI lexicon that match the specified wildcard pattern. This function requires the uri-lexicon database configuration parameter to be enabled. If the uri-lexicon database-configuration parameter is not enabled, an exception is thrown.

Parameters:
$pattern : Wildcard pattern to match.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
URIs should be returned in ascending order.
"descending"
URIs should be returned in descending order.
"any"
URIs from any fragment should be included.
"document"
URIs from document fragments should be included.
"properties"
URIs from properties fragments should be included.
"locks"
URIs from locks fragments should be included.
"frequency-order"
URIs should be returned ordered by frequency.
"item-order"
URIs should be returned ordered by item.
"sample=N"
Return only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include URIs from fragments selected by the cts:query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "sample=N" is not specfied in the options parameter, then all included URIs are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then URIs from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

If the $query parameter is not present and the current user is assigned the admin role, URIs from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see URIs from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:uri-match("http://foo.com/*.html")
  => ("http://foo.com/bar.html", "http://foo.com/baz/bork.html", ...)

cts:uris(
[$start as xs:string?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns values from the URI lexicon. This function requires the uri-lexicon database configuration parameter to be enabled. If the uri-lexicon database-configuration parameter is not enabled, an exception is thrown.

Parameters:
$start (optional): A starting value. Return only this value and following values. If the empty string, return all values. If the parameter is is not in the lexicon, then it returns the values beginning with the next value.
$options (optional): Options. The default is ().

Options include:

"ascending"
URIs should be returned in ascending order.
"descending"
URIs should be returned in descending order.
"any"
URIs from any fragment should be included.
"document"
URIs from document fragments should be included.
"properties"
URIs from properties fragments should be included.
"locks"
URIs from locks fragments should be included.
"frequency-order"
URIs should be returned ordered by frequency.
"item-order"
URIs should be returned ordered by item.
"sample=N"
Return only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only URIs from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include URIs from fragments selected by the cts:query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "frequency-order" or "item-order" may be specified in the options parameter. If neither "frequency-order" nor "item-order" is specified, then the default is "item-order".

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending" if "item-order" is specified, and "descending" if "frequency-order" is specified.

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "sample=N" is not specfied in the options parameter, then all included URIs are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then URIs from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, URIs from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see URIs from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:uris("http://foo.com/")
  => ("http://foo.com/", "http://foo.com/bar.html", ...)

cts:word-match(
$pattern as xs:string,
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the word lexicon that match the wildcard pattern. This function requires the word lexicon to be enabled. If the word lexicon is not enabled, an exception is thrown.

Parameters:
$pattern : A wildcard pattern to match.
$options (optional): Options. The default is ().

Options include:

"case-sensitive"
A case-sensitive match.
"case-insensitive"
A case-insensitive match.
"diacritic-sensitive"
A diacritic-sensitive match.
"diacritic-insensitive"
A diacritic-insensitive match.
"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If neither "case-sensitive" nor "case-insensitive" is present, $pattern is used to determine case sensitivity. If $pattern contains no uppercase, it specifies "case-insensitive". If $pattern contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $pattern is used to determine diacritic sensitivity. If $pattern contains no diacritics, it specifies "diacritic-insensitive". If $pattern contains diacritics, it specifies "diacritic-sensitive".

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

      cts:and-query(()) 

Example:
  cts:word-match("aardvark*")
  => ("aardvark","aardvarks")

cts:word-query(
$text as xs:string*,
[$options as xs:string*],
[$weight as xs:double]
)  as  cts:word-query
Summary:

Returns a query matching text content containing a given phrase.

Parameters:
$text : Some words or phrases to match. When multiple strings are specified, the query matches if any string matches.
$options (optional): Options to this query. The default is ().

Options include:

"case-sensitive"
A case-sensitive query.
"case-insensitive"
A case-insensitive query.
"diacritic-sensitive"
A diacritic-sensitive query.
"diacritic-insensitive"
A diacritic-insensitive query.
"punctuation-sensitive"
A punctuation-sensitive query.
"punctuation-insensitive"
A punctuation-insensitive query.
"whitespace-sensitive"
A whitespace-sensitive query.
"whitespace-insensitive"
A whitespace-insensitive query.
"stemmed"
A stemmed query.
"unstemmed"
An unstemmed query.
"wildcarded"
A wildcarded query.
"unwildcarded"
An unwildcarded query.
"exact"
An exact match query. Shorthand for "case-sensitive", "diacritic-sensitive", "punctuation-sensitive", "whitespace-sensitive", "unstemmed", and "unwildcarded".
"lang=iso639code"
Specifies the language of the query. The iso639code code portion is case-insensitive, and uses the languages specified by ISO 639. The default is specified in the database configuration.
$weight (optional): A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be less than or equal to the absolute value of 16 (between -16 and 16); weights greater than 16 will have the same effect as a weight of 16. Weights less than the absolute value of 0.0625 (between -0.0625 and 0.0625) are rounded to 0, which means that they do not contribute to the score.

Usage Notes:

If neither "case-sensitive" nor "case-insensitive" is present, $text is used to determine case sensitivity. If $text contains no uppercase, it specifies "case-insensitive". If $text contains uppercase, it specifies "case-sensitive".

If neither "diacritic-sensitive" nor "diacritic-insensitive" is present, $text is used to determine diacritic sensitivity. If $text contains no diacritics, it specifies "diacritic-insensitive". If $text contains diacritics, it specifies "diacritic-sensitive".

If neither "punctuation-sensitive" nor "punctuation-insensitive" is present, $text is used to determine punctuation sensitivity. If $text contains no punctuation, it specifies "punctuation-insensitive". If $text contains punctuation, it specifies "punctuation-sensitive".

If neither "whitespace-sensitive" nor "whitespace-insensitive" is present, the query is "whitespace-insensitive".

If neither "wildcarded" nor "unwildcarded" is present, the database configuration and $text determine wildcarding. If the database has any wildcard indexes enabled ("three character searches", "two character searches", "one character searches", or "trailing wildcard searches") and if $text contains either of the wildcard characters '?' or '*', it specifies "wildcarded". Otherwise it specifies "unwildcarded".

If neither "stemmed" nor "unstemmed" is present, then the database configuration determines if a query is run as "stemmed" (stemmed searches enabled) or "unstemmed" (word searches enabled and stemmed searches disabled). If the query is a wildcard query and is also a phrase query (contains two or more terms), then any wildcard terms in the query will be "unstemmed".


Example:
  cts:search(//function,
    cts:word-query("Mark Logic Corporation"))
  
=> .. relevance-ordered sequence of 'function' element ancestors (or self) of any node containing the phrase 'Mark Logic Corporation'.
Example:
  cts:search(//function,
    cts:word-query("Mark Logic Corporation", 
                   "case-insensitive"))
  => .. relevance-ordered sequence of 'function' 
  element ancestors (or self) of any node containing 
  the phrase 'Mark Logic Corporation' or any other 
  case-shift like 'Mark Logic Corporation', 
  'MARK Logic Corporation', etc.
Example:
  cts:search(//SPEECH,
    cts:word-query("to be, or not to be", 
                   "punctuation-insensitive"))
  => .. relevance-ordered sequence of 'SPEECH' 
  element ancestors (or self) of any node 
  containing the phrase 'to be, or not to be', 
  ignoring punctuation.

cts:word-query-options(
$query as cts:word-query
)  as  xs:string*
Summary:

Returns the options for the specified query.

Parameters:
$query : A query.

Example:
  cts:word-query-options($query)
  => ("case-sensitive", "punctuation-insensitive")

cts:word-query-text(
$query as cts:word-query
)  as  xs:string*
Summary:

Returns the text used to construct the specified query.

Parameters:
$query : A query.

Example:
  cts:word-query-text($query)
  => "choice of law"

cts:word-query-weight(
$query as cts:word-query
)  as  xs:double
Summary:

Returns the weight with which the specified query was constructed.

Parameters:
$query : A query.

Example:
  cts:word-query-weight($query)
  => 1

cts:words(
[$start as xs:string?],
[$options as xs:string*],
[$query as cts:query?],
[$quality-weight as xs:double],
[$forest-ids as xs:unsignedLong*]
)  as  xs:string*
Summary:

Returns words from the word lexicon. This function requires the word lexicon to be enabled. If the word lexicon is not enabled, an exception is thrown. The words are returned in collation order.

Parameters:
$start (optional): A starting word. Returns only this word and any following words from the lexicon. If the parameter is not in the lexicon, then it returns the words beginning with the next word.
$options (optional): Options. The default is ().

Options include:

"ascending"
Words should be returned in ascending order.
"descending"
Words should be returned in descending order.
"any"
Words from any fragment should be included.
"document"
Words from document fragments should be included.
"properties"
Words from properties fragments should be included.
"locks"
Words from locks fragments should be included.
"collation=URI"
Use the lexicon with the collation specified by URI.
"sample=N"
Return only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"truncate=N"
Include only words from the first N fragments selected by the cts:query. Only applies when a $query parameter is specified.
"score-logtfidf"
Compute scores using the logtfidf method.
"score-logtf"
Compute scores using the logtf method.
"score-simple"
Compute scores using the simple method.
"checked"
Word positions should be checked when resolving the query.
"unchecked"
Word positions should not be checked when resolving the query.
$query (optional): Only include words in fragments selected by the cts:query. The words do not need to match the query, but the words must occur in fragments selected by the query. The fragments are not filtered to ensure they match the query, but instead selected in the same manner as "unfiltered" cts:search operations. If a string is entered, the string is treated as a cts:word-query of the specified string.
$quality-weight (optional): A document quality weight to use when computing scores. The default is 1.0.
$forest-ids (optional): A sequence of IDs of forests to which the search will be constrained. An empty sequence means to search all forests in the database. The default is ().

Usage Notes:

Only one of "ascending" or "descending" may be specified in the options parameter. If neither "ascending" nor "descending" is specified, then the default is "ascending".

Only one of "any", "document", "properties", or "locks" may be specified in the options parameter. If none of "any", "document", "properties", or "locks" are specified and there is a $query parameter, then the default is "document". If there is no $query parameter then the default is "any".

Only one of the "score-logtfidf", "score-logtf", or "score-simple" options may be specified in the options parameter. If none of "score-logtfidf", "score-logtf", or "score-simple", are specified, then the default is "score-logtfidf".

Only one of the "checked" or "unchecked" options may be specified in the options parameter. If neither "checked" nor "unchecked" are specified, then the default is "checked".

If "collation=URI" is not specified in the options parameter, then the default collation is used. If a lexicon with that collation does not exist, an error is thrown.

If "sample=N" is not specfied in the options parameter, then all included words are returned. If a $query parameter is not present, then "sample=N" has no effect.

If "truncate=N" is not specfied in the options parameter, then words from all fragments selected by the $query parameter are included. If a $query parameter is not present, then "truncate=N" has no effect.

If the $query parameter is not present and the current user is assigned the admin role, words from deleted fragments not yet expunged by a merge may be included. Users who are not part of the admin role will not see words from deleted fragments. To filter deleted fragments for the admin role case, use a $query parameter. For example, the following query returns all documents, but would have the effect of filtering out deleted fragments for admin users:

    cts:words("abc", (), cts:and-query(()))

Example:
  cts:words("aardvark")
  => ("aardvark","aardvarks","aardwolf",...)