/** * A convenience 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. * * @example * var idx = lunr(function () { * this.field('title') * this.field('body') * this.ref('id') * * documents.forEach(function (doc) { * this.add(doc) * }, this) * }) * * @see {@link lunr.Builder} * @see {@link lunr.Pipeline} * @see {@link lunr.trimmer} * @see {@link lunr.stopWordFilter} * @see {@link lunr.stemmer} * @namespace {function} lunr */ var lunr = function (config) { var builder = new lunr.Builder builder.pipeline.add( lunr.trimmer, lunr.stopWordFilter, lunr.stemmer ) builder.searchPipeline.add( lunr.stemmer ) config.call(builder, builder) return builder.build() } lunr.version = "@VERSION"