Loading TOC...


   mapper as objectOrFuncRef
) as WordsSearch


Specifies a function similar to Array.prototype.map() to apply to each word within the slice. Exclusive with respect to the reduce() clause.

mapper A configuration object for the built-in mapper, or a reference to a custom mapper function. See the Usage Notes for details.

Usage Notes

Your custom mapper function is invoked on each word in the current slice. Your custom mapper should have the following signature:

function (currentItem)

Where currentItem is the current word to act on. If the function returns a value, the value is added to the results array or iterator.

You cannot use this method in conjunction with WordsSearch.reduce.

See Also


// Returns true if the input is on my black list
function isInBlackList(word) {...};

const jsearch = require('/MarkLogic/jsearch.sjs');
  .map(function (word) {
    return isInBlackList(word) ? undefined : word

// Result: An array of words in the 'title' word lexicon that are not blacklisted

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