Loading TOC...

jsearch.documentSelect

jsearch.documentSelect(
   results as Document[],
   configuration as object
) as iterator

Summary

Applies document selection logic to the documents returned by cts.search, fn.collection, fn.doc, or another document iterator or to an array of documents or one document.

Parameters
results An iterator or array for documents or a document.
configuration The options for configuring document selection.

Usage Notes

Use this method to generate snippets, sparse document projects, and/or a set of similar documents from an arbitrary set of documents, such as the result of calling cts.search or fn.doc. To perform these same operations on a normal JSearch document search, use jsearch.documents.

The configuration options are the same as those for DocumentSearch.map with the following differences:

snippets
The query property of the snippets configuration is required to produce snippets.
start
Specifies the zero-based index of the first document for identifying the result documents.
searchOptions
Specifies the options used for cts.search() when the result list is the iterator returned by cts.search() or fn.subsequence(cts.search()). The options are necessary only when they include "relevance-trace"

See Also

Example


// Generate snippets for results returned by cts.search.
const jsearch = require('/MarkLogic/jsearch.sjs');
const myQuery = 
    cts.andQuery([
      cts.directoryQuery('/books/'), 
      cts.jsonPropertyWordQuery('synopsis', 'california')])
jsearch.documentSelect(
  cts.search(myQuery),
  {snippet: {query: myQuery}})
   

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