jsearch.tuples( $index as cts.reference ) as TuplesSearch
Creates a TuplesSearch object to define and execute a search for a list of rows where the values in each row co-occur in indexes for a document.
|$index||An array of cts.reference objects for range indexes or other value lexicons (such as those for uris or collections). As a shortcut, you can pass the name of a JSON property with a range index as a string.|
Use the methods of
TuplesSearch to tailor your
query. For example, scope your query to the values in documents
matching a documents query, define a sort order, or compute an
aggregate over the co-occurrences.
// Find co-occurrences of the "author" and "format" JSON properties // in documents in "/books/" directory. var jsearch = require('/MarkLogic/jsearch.sjs'); jsearch.tuples(['author','format']) .where(cts.directoryQuery('/books/')) .orderBy('item') .result() ==> Co-occurence values similar to the following: [["John Steinbeck", "audiobook"], ["John Steinbeck", "hardback"], ["John Steinbeck", "paperback"], ["Mark Twain", "hardback"], ["Mark Twain", "paperback"], ["Robert Frost", "paperback"]]