Loading TOC...

jsearch.tuples

jsearch.tuples(
   index as cts.reference
) as TuplesSearch

Summary

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.

Parameters
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.

Usage Notes

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.

See Also

Example


// Find co-occurrences of the "author" and "format" JSON properties
// in documents in "/books/" directory.
const jsearch = require('/MarkLogic/jsearch.sjs');
jsearch.tuples(['author','format'])
  .where(cts.directoryQuery('/books/'))
  .orderBy('item')
  .result()

/* 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"]]
*/
   

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