
op.fromSearchDocs( query as cts.query, [qualifier as String?], [options as objectLiteral] ) as ModifyPlan
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 |
An object with options similar to cts.search.
The results are ordered by score by default. Options include:
|
The op.fromSearchDocs function is a convenience for executing
a op.fromSearch equivalent to:
function fromSearchDocs(query, qualifier, options) {
return op.fromSearch(query, ['confidence', 'fitness', 'fragmentId', 'quality', 'score'], qualifier, options)
.orderBy(desc('score'));
.joinDocAndUri('doc','uri', fragmentIdCol('fragmentId'))
}
Please note that if you have other Optic functions following op.fromSearchDocs, it may change
the ordering of the results.
// 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();
const op = require('/MarkLogic/optic');
op.fromSearchDocs('tiger',
null,
{scoreMethod:'bm25', bm25LengthWeight:0.5})
.result();