cts:json-property-value-query( $property-name as xs:string*, $value as xs:anyAtomicType*, [$options as xs:string*], [$weight as xs:double?] ) as cts:json-property-value-query
Returns a query matching JSON properties by name with value equal the given value. For arrays, the query matches if the value of any elements in the array matches the given value.
Parameters | |
---|---|
property-name | One or more property names to match. When multiple names are specified, the query matches if any name matches. |
value | One or more property values to match. When multiple values are specified, the query matches if any value matches. The values can be strings, numbers or booleans to match correspondingly typed nodes. If the value is the empty sequence, the query matches null. |
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.
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 you use the "exact" option, you should also enable "fast case sensitive searches" and "fast diacritic sensitive searches" in your database configuration.
Note that the text content for the value in a
cts:json-property-value-query
is treated the same as a phrase in a
cts:word-query
, where the phrase is the property value.
Therefore, any wildcard and/or stemming rules are treated like a phrase.
For example, if you have an property value of "hello friend" with wildcarding
enabled for a query, a cts:json-property-value-query
for "he*" will
not match because the wildcard matches do not span word boundaries, but a
cts:json-property-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.
Similarly, because a "*" wildcard by itself is defined to match
the value, the following query will match any property with the
name my-property
, regardless of the wildcard indexes enabled in
the database configuration:
cts:json-property-value-query("my-property", "*", "wildcarded")
cts:search(//module, cts:json-property-value-query( "function", "MarkLogic Corporation")) => .. relevance-ordered sequence of 'module' property ancestors of 'function' properties whose text content equals 'MarkLogic Corporation'.
cts:search(//module, cts:json-property-value-query( "function", "MarkLogic Corporation", "case-insensitive")) => .. relevance-ordered sequence of 'module' property ancestors of 'function' properties whose text content equals 'MarkLogic Corporation', or any other case-shift like 'MARKLOGIC CorpoRation'.
cts:search(//module, cts:and-query(( cts:json-property-value-query( "function", "MarkLogic Corporation", "punctuation-insensitive", 0.5), cts:json-property-value-query( "title", "Word Query")))) => .. relevance-ordered sequence of 'module' properties which are ancestors of both: (a) 'function' properties with text content equal to 'MarkLogic Corporation', ignoring embedded punctuation, AND (b) 'title' properties 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.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.