elasticlunr

tokenizer

method
elasticlunr.tokenizer()

Option name Type Description
obj String

The string to convert into tokens

return Array

A function for splitting a string into tokens ready to be inserted into
the search index.

elasticlunr.tokenizer = function (obj) {
  if (!arguments.length || obj == null || obj == undefined) return []
  if (Array.isArray(obj)) return obj.map(function (t) { return t.toLowerCase() })

  return obj.toString().trim().toLowerCase().split(/[\s\-]+/)
}