cts.elementAttributeValueQuery( element-name as xs.QName[], attribute-name as xs.QName[], text as String[], [options as String[]], [weight as Number?] ) as cts.elementAttributeValueQuery
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 |
Options to this query. The default is ().
Options include:
|
weight | A weight for this query. Higher weights move search results up in the relevance order. The default is 1.0. The weight should be between 64 and -16. Weights greater than 64 will have the same effect as a weight of 64. 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. |
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, the database configuration determines stemming. If the database has "stemmed searches" enabled, it specifies "stemmed". Otherwise it specifies "unstemmed". If the query is a wildcarded query and also a phrase query (contains two or more terms), the wildcard terms in the query are unstemmed.
When you use the "exact" option, you should also enable "fast case sensitive searches" and "fast diacritic sensitive searches" in your database configuration.
Negative "min-occurs" or "max-occurs" values will be treated as 0 and non-integral values will be rounded down. An error will be raised if the "min-occurs" value is greater than the "max-occurs" value.
When multiple element and/or attribute QNames are specified, then all possible element/attribute QName combinations are used to select the matching values.
cts.search( cts.elementAttributeValueQuery( xs.QName("function"), xs.QName("type"), "MarkLogic Corporation")); => .. relevance-ordered sequence of documents having 'function' elements that have an attribute 'type' whose value equals 'MarkLogic Corporation'.
cts.search( cts.andQuery([ cts.elementAttributeValueQuery( xs.QName("function"), xs.QName("type"), "MarkLogic Corporation", null, 0.5), cts.elementWordQuery( xs.QName("title"), "faster")])); => .. relevance-ordered sequence documents having both: (a) 'function' elements with attribute 'type' whose value equals the string 'MarkLogic 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.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.