Loading TOC...

DocumentsSearch.slice

DocumentsSearch.slice(
   start as integer,
   end as integer
) as DocumentsSearch

Summary

Specifies a subsequence of matched, sorted, and filtered documents to retrieve. If unspecified, the slice defaults to the first 10 documents.

Parameters
start The zero-based index of the first document to return.
end The zero-based index of the document after the last document to return. If unspecified, the end defaults to specify a subsequence of 10 documents.

See Also

Example


// Find documents containing the word "california" in the "title"
// JSON property, and return the first 5 results.
const jsearch = require('/MarkLogic/jsearch.sjs');
jsearch.documents()
  .where(cts.parse('title:california'))
  .slice(0,5)
  .result()
   

Example


// Return 10 documents, beginning with the 20th result
const jsearch = require('/MarkLogic/jsearch.sjs');
jsearch.documents()
  .slice(20,30)
  .result()
   

Example


// Suppress inclusion of matched documents (or snippets)
const jsearch = require('/MarkLogic/jsearch.sjs');

jsearch.documents()
  .where(cts.jsonPropertyValueQuery('author', 'Mark Twain'))
  .slice(0,0)
  .result()

/* Result: Search results that contain an estimate, but no search metadata 
   or matching documents. Output will be similar to the following:

{ results: null, estimate: 4 }
*/
   

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