Loading TOC...

MarkLogic Server 11.0 Product Documentation
TuplesSearch functions (TuplesSearch)

Use these functions to find n-way value co-occurrences across lexicons and range indexes and to compute aggregates from co-occurrences. Create a tuples query builder using jsearch.tuples, then build up the query by chaining calls to methods such as where and orderBy. Finally, execute the query by calling result.

To use this module in your Server-Side JavaScript code, include a require statement similar to following line in your code:

const jsearch = require("/MarkLogic/jsearch");
    

The order in which you call the methods of this class is significant. You should preserve the order shown in the templates below. For details, see Query Design Pattern in the Search Developer's Guide.

The intended usage for retrieving tuples is as follows, with everything except the call to tuples and result being optional.

Use the following form for finding co-occurrences in lexicons and range index:

jsearch.tuples(jsonPropNamesOrIndexRefs)       // creates a TuplesSearch object
  .where(queries)
  .orderBy(orderingConfig)
  .slice(startPos, endPosPlusOne)
  .map(funcRef) | .reduce(funcRef, optionalSeed)
  .withOptions(optionsConfig)
  .result()
    

Use the following form for computing aggregates over lexicon and range index co-occurrences:

jsearch.tuples(jsonPropNamesOrWordlexiconRefs)
  .where(queries)
  .aggregate(builtinAggregateOrUDF)
  .withOptions(optionsConfig)
  .result()
    

For details, see jsearch.tuples, TuplesSearch, and Querying Lexicons and Range Indexes in the Search Developer's Guide.

8 functions
Function name Description
TuplesSearch.aggregate Applies one or more aggregates to the tuples.
TuplesSearch.map Specifies a function similar to Array.prototype.map() to apply to each tuple within the slice or the configuration for the built-in mapper.
TuplesSearch.orderBy Specifies the sort method for the tuples.
TuplesSearch.reduce Specifies a function similar to Array.prototype.reduce() to apply to each tuple within the slice.
TuplesSearch.result Executes the tuples search definition and returns results.
TuplesSearch.slice Specifies a subset of tuples to retrieve.
TuplesSearch.where Specifies which documents have the co-occurring values.
TuplesSearch.withOptions Configure advanced options for a tuples query.