marklogic Fetching all the documents with word "marklogic", document in collection "first-collection"


Example

This can be done in the following two ways -

cts:search(
    fn:collection("first-collection"), 
    cts:word-query("marklogic"))

In this, the scope is changed from all the documents to documents in collection "first-collection" only.

In the second approach, use of cts:collection-query has been made. This should give better performance than the first approach.

cts:search(
    fn:doc(), 
    cts:and-query((
        cts:collection-query("first-collection"),
        cts:word-query("marklogic")))