1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- /**
- * Convenience function for instantiating a new lunr index and configuring it
- * with the default pipeline functions and the passed config function.
- *
- * When using this convenience function a new index will be created with the
- * following functions already in the pipeline:
- *
- * lunr.StopWordFilter - filters out any stop words before they enter the
- * index
- *
- * lunr.stemmer - stems the tokens before entering the index.
- *
- * Example:
- *
- * var idx = lunr(function () {
- * this.field('title', 10)
- * this.field('tags', 100)
- * this.field('body')
- *
- * this.ref('cid')
- *
- * this.pipeline.add(function () {
- * // some custom pipeline function
- * })
- *
- * })
- *
- * @param {Function} config A function that will be called with the new instance
- * of the lunr.Index as both its context and first parameter. It can be used to
- * customize the instance of new lunr.Index.
- * @namespace
- * @module
- * @returns {lunr.Index}
- *
- */
- var lunr = function (config) {
- var idx = new lunr.Index
- idx.pipeline.add(
- lunr.trimmer,
- lunr.stopWordFilter,
- lunr.stemmer
- )
- if (config) config.call(idx, idx)
- return idx
- }
- lunr.version = "@VERSION"
|