Loading TOC...


   query as cts.query,
   [columns as columnIdentifier[]],
   [qualifier as String?],
   [options as objectLiteral]
) as ModifyPlan


This function dynamically constructs a row set based on a cts.query where the columns for the document fragment id and score reflecting the degree of match of the document with the query criteria.

By joining on the document fragment id, a query can add the score to the rows, triples, lexicon values, or content provided by the document.

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.
columns Specifies which of the available columns to include in the rows. The available columns include the metrics for relevance ('confidence', 'fitness', 'quality', and 'score') and fragmentId for the document identifier. By default, the rows have the fragmentId and score columns. To rename a column, use op.as specifying the new name for an op.col with the old name.
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', or 'simple' 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.

Usage Notes

The fromSearch function is one of the Data Access Functions.

See Also


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

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

   op.fromSearch(cts.jsonPropertyValueQuery('experience', 'design'),
                ['fragmentId', 'score', 'quality'])
     .joinInner(op.fromView(null, 'employee', '', op.fragmentIdCol('rowsDocId')),
                op.on('fragmentId', 'rowsDocId'))

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