MarkLogic 10 Product Documentation
WordsSearch functions (WordsSearch)

Use these functions to query and compute aggregates over words in a word lexicons. Create a words query builder using jsearch.words, 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 template below. For details, see Query Design Pattern in the Search Developer's Guide.

Use the following form for querying the values in a lexicon or range index. All the calls except jsearch.words and result are optional.

jsearch.words(jsonPropNamesOrWordLexiconRefs)
  .where(queries)
  .match(pattern)
  .orderBy(orderingConfig)
  .slice(startPos, endPosPlusOne)
  .map(funcRef) | .reduce(funcRef, optionalSeed)
  .withOptions(optionsConfig)
  .result()
    

For details, see jsearch.words, WordsSearch, and Querying Values in a Word Lexicon in the Search Developer's Guide.

8 functions
Function name Description
WordsSearch.map Specifies a function similar to Array.prototype.map() to apply to each word within the slice.
WordsSearch.match Limits the words returned by a word lexicon query to those that match a wildcard pattern.
WordsSearch.orderBy Specifies the sort order for the words.
WordsSearch.reduce Specifies a function similar to Array.prototype.reduce() to apply to each word within the slice.
WordsSearch.result Executes the words search definition and returns an array or object depending on whether the results are generated by default, with a mapper, or with a reducer.
WordsSearch.slice Specify a positional subset of words to retrieve.
WordsSearch.where Limit the words returned by a word lexicon query to those in documents selected by a query.
WordsSearch.withOptions Configure advanced options for a words query.
Powered by MarkLogic Server | Terms of Use | Privacy Policy