
jsearch.collections( uris as xs.string ) as jsearch
Creates a jsearch object for searching within the scope of the union of one or more collections.
| Parameters | |
|---|---|
| uris | One or an array of collection URIs. When you specify multiple URIs, a document is included if it is in at least one of the collections. |
jsearch object created by this method,
it effectively appends a cts.collectionQuery to any
where clause with which it used. To apply a collection
constraint to a specify sub-query or to use boolean composition of
collection queries (e.g. collection1 AND collection2), use an
explicitly cts.collectionQuery instead of (or in addition to)
this method.
// Match documents in the "Classics" collection with author "Mark Twain"
const classics = require('/MarkLogic/jsearch.sjs').collections('Classics');
classics.documents()
.where( classics.byExample({author: 'Mark Twain'}) )
.result()
// Find words in the "title" word lexicon that occur in documents
// in the "poetry" or "literature" collections.
const favorites = require('/MarkLogic/jsearch.sjs')
.collections(['poetry', 'literature']);
favorites.words('title').result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.