Namespace: lunr

lunr

A convinience function for configuring and constructing a new lunr Index.

A lunr.Builder instance is created and the pipeline setup with a trimmer, stop word filter and stemmer.

This builder object is yielded to the configuration function that is passed as a parameter, allowing the list of fields and other builder parameters to be customised.

All documents must be added within the passed config function.

Source:
See:

Example

var idx = lunr(function () {
  this.field('title')
  this.field('body')
  this.ref('id')

  documents.forEach(function (doc) {
    this.add(doc)
  }, this)
})

Classes

Builder
Index
MatchData
Pipeline
Query
Token
TokenSet
Vector

Members

(static) stemmer

lunr.stemmer is an english language stemmer, this is a JavaScript implementation of the PorterStemmer taken from http://tartarus.org/~martin

Implements:
Source:
See:

(static) stopWordFilter

lunr.stopWordFilter is an English language stop word list filter, any words contained in the list will not be passed through the filter.

This is intended to be used in the Pipeline. If the token does not pass the filter then undefined will be returned.

Implements:
Source:
See:

(static) utils

A namespace containing utils for the rest of the lunr library

Source:

Methods

(static) generateStopWordFilter(token) → {lunr.PipelineFunction}

lunr.generateStopWordFilter builds a stopWordFilter function from the provided list of stop words.

The built in lunr.stopWordFilter is built using this generator and can be used to generate custom stopWordFilters for applications or non English languages.

Parameters:
Name Type Description
token Array

The token to pass through the filter

Source:
See:
Returns:
Type
lunr.PipelineFunction

(static) tokenizer(objnullable) → {Array.<lunr.Token>}

A function for splitting a string into tokens ready to be inserted into the search index. Uses lunr.tokenizer.seperator to split strings, change the value of this property to change how strings are split into tokens.

This tokenizer will convert its parameter to a string by calling toString and then will split this string on the character in lunr.tokenizer.seperator. Arrays will have their elements converted to strings and wrapped in a lunr.Token.

Parameters:
Name Type Attributes Description
obj string | object | Array.<object> <nullable>

The object to convert into tokens

Source:
Returns:
Type
Array.<lunr.Token>

(static) trimmer(token) → {lunr.Token}

lunr.trimmer is a pipeline function for trimming non word characters from the begining and end of tokens before they enter the index.

This implementation may not work correctly for non latin characters and should either be removed or adapted for use with languages with non-latin characters.

Parameters:
Name Type Description
token lunr.Token

The token to pass through the filter

Implements:
Source:
See:
Returns:
Type
lunr.Token