Loading TOC...

MarkLogic 10 Product Documentation
ValuesSearch functions (ValuesSearch)

Use these functions to query and compute aggregates over values in lexicons and range indexes. Create a tuples query builder using jsearch.values, then build up the query by chaining calls to methods such as where and orderBy. Finally, execute the query by calling the result method.

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.

Use the following form to query the values in an index or lexicon, with everything except the call to values and result being optional.

jsearch.values(jsonPropNamesOrIndexRefs)           // creates a ValuesSearch obj
  .where(queries)
  .match(pattern) | .groupInto(bucketDefinitions)
  .orderBy(orderingConfig)
  .slice(startPos, endPosPlusOne)
  .map(configOrFuncRef) | .reduce(funcRef, optionalSeed)
  .withOptions(optionsConfig)
  .result()
    

Use the following form for computing aggregates over the values in a lexicon or range index. The calls to where and withOptions are optional.

jsearch.values(jsonPropNamesOrWordLexiconRefs)
  .where(queries)
  .aggregate(builtinAggregateOrUDF)
  .withOptions(optionsConfig)
  .result()
    

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

10 functions
Function name Description
ValuesSearch.aggregate Applies one or more aggregates to the values in the index.
ValuesSearch.groupInto Groups the values into buckets between bound values, which must appear in increasing order.
ValuesSearch.map Specify a function similar to Array.prototype.map() to apply to each value within the slice, or configure the built-in mapper.
ValuesSearch.match Limits the values to those that match the pattern.
ValuesSearch.orderBy Specifies the sort order for values.
ValuesSearch.reduce Specifies a function similar to Array.prototype.reduce() to apply to each value within the slice or a configuration object for the built-in reducer.
ValuesSearch.result Executes the values search definition and returns an array or object depending on whether the results are generated by default, with a mapper, or with a reducer.
ValuesSearch.slice Specifies a subsequence of values to retrieve.
ValuesSearch.where Specifies which documents have values in the index.
ValuesSearch.withOptions Configure advanced options for a values query.