Loading TOC...

DocumentsSearch functions (DocumentsSearch)

Use these functions to search document content and document properties.

To use this module in your Server-Side JavaScript code, include a require statement similar to following line in your code:

const jsearch = require("/MarkLogic/jsearch");

The usage model for these methods is as follows: Create a document search builder using jsearch.documents, then chain calls to methods such as where and orderBy on the resulting object. Finally, execute the query by calling the result method.

The order in which you call the methods of this class is significant. You should preserve the order shown in the template below. For details, see Query Design Pattern in the Search Developer's Guide.

Use the methods of this class in the following way, where everything except the call to documents and result being optional.

jsearch.documents()                         // creates a DocumentsSearch object
  .slice(startPos, endPosPlusOne)
  .map(configOrFuncRef) | .reduce(configOrFuncRef)

For details, see jsearch.documents, DocumentsSearch, and Searching Documents in the Search Developer's Guide.

8 functions
Function name Description
DocumentsSearch.filter Specifies filtering the documents by inspecting the contents of matched and ordered documents to populate the slice.
DocumentsSearch.map Specifies a function similar to Array.prototype.map() to apply to each document within the slice or the configuration for the built-in mapper.
DocumentsSearch.orderBy Specifies the sort order for matched documents.
DocumentsSearch.reduce Specifies a function similar to Array.prototype.reduce() to apply to each document within the slice.
DocumentsSearch.result Executes the document search definition and returns a result Iterable with an estimate property for the total number of matched documents, a results property with an array holding the subsequence of documents in the slice, and other properties if specified by withOptions().
DocumentsSearch.slice Specifies a subsequence of matched, sorted, and filtered documents to retrieve.
DocumentsSearch.where Specifies which documents to match based on the indexes over the documents.
DocumentsSearch.withOptions Configure advanced document search options.