op:from-search-docs( $query as cts:query, [$qualifier as xs:string?], [$options as map:map] ) as map:map
This function matches and returns the uri, content, and score for documents.
Parameters | |
---|---|
$query | Qualifies and establishes the scores for a set of documents. The query can be a cts:query or a string as a shortcut for a cts:word-query. |
$qualifier | Specifies a name for qualifying the column names. |
$options | Similar to the options of cts:search, supplies the 'scoreMethod' key with a value of 'logtfidf', 'logtf', 'simple', 'zero', 'random', or 'bm25' to specify the method for assigning a score to matched documents or supplies the 'qualityWeight' key with a numeric value to specify a multiplier for the quality contribution to the score. Specify a value between 0 (exclusive) and 1 (inclusive) for bm25LengthWeight if 'bm25' scoring method is used. |
The op:from-search-docs
function is a convenience for executing
a op:from-search equivalent to:
declare function local:from-search-docs($query as cts:query, $qualifier as xs:string?) as map:map { op:from-search($query, (), $qualifier) => op:join-doc-uri('uri', op:fragment-id-col('fragmentId')) => op:order-by(op:desc('score')) => op:join-doc('doc', op:fragment-id-col('fragmentId')) => op:order-by(op:desc('score')) };
(: Get the documents for top 20 employees with experience related to design :) xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; op:from-search-docs(cts:json-property-value-query('experience', 'design')) => op:limit(20) => op:result()
xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; op:from-search-docs('tiger', (), map:entry('scoreMethod', 'bm25') =>map:with('bm25LengthWeight', 0.5) ) => op:result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.