Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op.fromSearchDocs

op.fromSearchDocs(
   query as cts.query,
   [qualifier as String?],
   [options as objectLiteral]
) as ModifyPlan

Summary

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.wordQuery.
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.

Usage Notes

The op.fromSearchDocs function is a convenience for executing a op.fromSearch equivalent to:

function fromSearchDocs(query, qualifier) {
   return op.fromSearch(query, null, qualifier)
            .joinDocUri('uri', op.fragmentIdCol('fragmentId'))
            .orderBy(op.desc('score'))
            .joinDoc('doc', op.fragmentIdCol('fragmentId'))
            .orderBy(op.desc('score'));
}
  

See Also

Example

// Get the documents for top 20 employees with experience related to design

const op = require('/MarkLogic/optic');

   op.fromSearchDocs(cts.jsonPropertyValueQuery('experience', 'design'))
     .limit(20)
     .result();
  

Example

const op = require('/MarkLogic/optic');
op.fromSearchDocs('tiger',
            null,
            {scoreMethod:'bm25', bm25LengthWeight:0.5})
 .result();
  

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