Lines Matching defs:lunr

2  * lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 2.3.8
11 * a new lunr Index.
13 * A lunr.Builder instance is created and the pipeline setup
23 * var idx = lunr(function () {
33 * @see {@link lunr.Builder}
34 * @see {@link lunr.Pipeline}
35 * @see {@link lunr.trimmer}
36 * @see {@link lunr.stopWordFilter}
37 * @see {@link lunr.stemmer}
38 * @namespace {function} lunr
40 var lunr = function (config) {
41 var builder = new lunr.Builder
44 lunr.trimmer,
45 lunr.stopWordFilter,
46 lunr.stemmer
50 lunr.stemmer
57 lunr.version = "2.3.8"
59 * lunr.utils
64 * A namespace containing utils for the rest of the lunr library
65 * @namespace lunr.utils
67 lunr.utils = {}
73 * @memberOf lunr.utils
76 lunr.utils.warn = (function (global) {
95 * @memberOf lunr.utils
97 lunr.utils.asString = function (obj) {
121 lunr.utils.clone = function (obj) {
150 lunr.FieldRef = function (docRef, fieldName, stringValue) {
156 lunr.FieldRef.joiner = "/"
158 lunr.FieldRef.fromString = function (s) {
159 var n = s.indexOf(lunr.FieldRef.joiner)
168 return new lunr.FieldRef (docRef, fieldRef, s)
171 lunr.FieldRef.prototype.toString = function () {
173 this._stringValue = this.fieldName + lunr.FieldRef.joiner + this.docRef
179 * lunr.Set
184 * A lunr set.
188 lunr.Set = function (elements) {
207 * @type {lunr.Set}
209 lunr.Set.complete = {
228 * @type {lunr.Set}
230 lunr.Set.empty = {
250 lunr.Set.prototype.contains = function (object) {
258 * @param {lunr.Set} other - set to intersect with this set.
259 * @returns {lunr.Set} a new set that is the intersection of this and the specified set.
262 lunr.Set.prototype.intersect = function (other) {
265 if (other === lunr.Set.complete) {
269 if (other === lunr.Set.empty) {
290 return new lunr.Set (intersection)
296 * @param {lunr.Set} other - set to union with this set.
297 * @return {lunr.Set} a new set that is the union of this and the specified set.
300 lunr.Set.prototype.union = function (other) {
301 if (other === lunr.Set.complete) {
302 return lunr.Set.complete
305 if (other === lunr.Set.empty) {
309 return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements)))
319 lunr.idf = function (posting, documentCount) {
340 lunr.Token = function (str, metadata) {
350 lunr.Token.prototype.toString = function () {
358 * @callback lunr.Token~updateFunction
371 * @param {lunr.Token~updateFunction} fn - A function to apply to the token string.
372 * @returns {lunr.Token}
374 lunr.Token.prototype.update = function (fn) {
383 * @param {lunr.Token~updateFunction} [fn] - An optional function to apply to the cloned token.
384 * @returns {lunr.Token}
386 lunr.Token.prototype.clone = function (fn) {
388 return new lunr.Token (fn(this.str, this.metadata), this.metadata)
391 * lunr.tokenizer
397 * the search index. Uses `lunr.tokenizer.separator` to split strings, change
401 * then will split this string on the character in `lunr.tokenizer.separator`.
402 * Arrays will have their elements converted to strings and wrapped in a lunr.Token.
410 * @returns {lunr.Token[]}
411 * @see {@link lunr.Pipeline}
413 lunr.tokenizer = function (obj, metadata) {
420 return new lunr.Token(
421 lunr.utils.asString(t).toLowerCase(),
422 lunr.utils.clone(metadata)
435 if ((char.match(lunr.tokenizer.separator) || sliceEnd == len)) {
438 var tokenMetadata = lunr.utils.clone(metadata) || {}
443 new lunr.Token (
460 * `lunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens.
463 * @see lunr.tokenizer
465 lunr.tokenizer.separator = /[\s\-]+/
467 * lunr.Pipeline
472 * lunr.Pipelines maintain an ordered list of functions to be applied to all
476 * An instance of lunr.Index created with the lunr shortcut will contain a
491 * a pipeline should be registered with lunr.Pipeline. Registered functions can
500 lunr.Pipeline = function () {
504 lunr.Pipeline.registeredFunctions = Object.create(null)
507 * A pipeline function maps lunr.Token to lunr.Token. A lunr.Token contains the token
518 * Any number of pipeline functions may be chained together using a lunr.Pipeline.
520 * @interface lunr.PipelineFunction
521 * @param {lunr.Token} token - A token from the document being processed.
523 * @param {lunr.Token[]} tokens - All tokens for this document/field.
524 * @returns {(?lunr.Token|lunr.Token[])}
536 * @param {lunr.PipelineFunction} fn - The function to check for.
539 lunr.Pipeline.registerFunction = function (fn, label) {
541 lunr.utils.warn('Overwriting existing registered function: ' + label)
545 lunr.Pipeline.registeredFunctions[fn.label] = fn
551 * @param {lunr.PipelineFunction} fn - The function to check for.
554 lunr.Pipeline.warnIfFunctionNotRegistered = function (fn) {
558 lunr.utils.warn('Function is not registered with pipeline. This may cause problems when serialising the index.\n', fn)
565 * All functions to be loaded must already be registered with lunr.Pipeline.
570 * @returns {lunr.Pipeline}
572 lunr.Pipeline.load = function (serialised) {
573 var pipeline = new lunr.Pipeline
576 var fn = lunr.Pipeline.registeredFunctions[fnName]
593 * @param {lunr.PipelineFunction[]} functions - Any number of functions to add to the pipeline.
595 lunr.Pipeline.prototype.add = function () {
599 lunr.Pipeline.warnIfFunctionNotRegistered(fn)
610 * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.
611 * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.
613 lunr.Pipeline.prototype.after = function (existingFn, newFn) {
614 lunr.Pipeline.warnIfFunctionNotRegistered(newFn)
631 * @param {lunr.PipelineFunction} existingFn - A function that already exists in the pipeline.
632 * @param {lunr.PipelineFunction} newFn - The new function to add to the pipeline.
634 lunr.Pipeline.prototype.before = function (existingFn, newFn) {
635 lunr.Pipeline.warnIfFunctionNotRegistered(newFn)
648 * @param {lunr.PipelineFunction} fn The function to remove from the pipeline.
650 lunr.Pipeline.prototype.remove = function (fn) {
666 lunr.Pipeline.prototype.run = function (tokens) {
703 lunr.Pipeline.prototype.runString = function (str, metadata) {
704 var token = new lunr.Token (str, metadata)
715 lunr.Pipeline.prototype.reset = function () {
726 lunr.Pipeline.prototype.toJSON = function () {
728 lunr.Pipeline.warnIfFunctionNotRegistered(fn)
734 * lunr.Vector
754 lunr.Vector = function (elements) {
770 lunr.Vector.prototype.positionForIndex = function (index) {
822 lunr.Vector.prototype.insert = function (insertIdx, val) {
836 lunr.Vector.prototype.upsert = function (insertIdx, val, fn) {
852 lunr.Vector.prototype.magnitude = function () {
869 * @param {lunr.Vector} otherVector - The vector to compute the dot product with.
872 lunr.Vector.prototype.dot = function (otherVector) {
898 * @param {lunr.Vector} otherVector - The other vector to calculate the
902 lunr.Vector.prototype.similarity = function (otherVector) {
911 lunr.Vector.prototype.toArray = function () {
926 lunr.Vector.prototype.toJSON = function () {
931 * lunr.stemmer
937 * lunr.stemmer is an english language stemmer, this is a JavaScript
941 * @implements {lunr.PipelineFunction}
942 * @param {lunr.Token} token - The string to stem
943 * @returns {lunr.Token}
944 * @see {@link lunr.Pipeline}
947 lunr.stemmer = (function(){
1151 lunr.Pipeline.registerFunction(lunr.stemmer, 'stemmer')
1153 * lunr.stopWordFilter
1158 * lunr.generateStopWordFilter builds a stopWordFilter function from the provided
1161 * The built in lunr.stopWordFilter is built using this generator and can be used
1166 * @returns {lunr.PipelineFunction}
1167 * @see lunr.Pipeline
1168 * @see lunr.stopWordFilter
1170 lunr.generateStopWordFilter = function (stopWords) {
1182 * lunr.stopWordFilter is an English language stop word list filter, any words
1189 * @implements {lunr.PipelineFunction}
1190 * @params {lunr.Token} token - A token to check for being a stop word.
1191 * @returns {lunr.Token}
1192 * @see {@link lunr.Pipeline}
1194 lunr.stopWordFilter = lunr.generateStopWordFilter([
1316 lunr.Pipeline.registerFunction(lunr.stopWordFilter, 'stopWordFilter')
1318 * lunr.trimmer
1323 * lunr.trimmer is a pipeline function for trimming non word
1332 * @implements {lunr.PipelineFunction}
1333 * @param {lunr.Token} token The token to pass through the filter
1334 * @returns {lunr.Token}
1335 * @see lunr.Pipeline
1337 lunr.trimmer = function (token) {
1343 lunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')
1345 * lunr.TokenSet
1370 lunr.TokenSet = function () {
1373 this.id = lunr.TokenSet._nextId
1374 lunr.TokenSet._nextId += 1
1385 lunr.TokenSet._nextId = 1
1391 * @returns {lunr.TokenSet}
1394 lunr.TokenSet.fromArray = function (arr) {
1395 var builder = new lunr.TokenSet.Builder
1409 * @param {Object} clause - A single clause from lunr.Query.
1412 * @returns {lunr.TokenSet}
1414 lunr.TokenSet.fromClause = function (clause) {
1416 return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance)
1418 return lunr.TokenSet.fromString(clause.term)
1435 * @returns {lunr.Vector}
1437 lunr.TokenSet.fromFuzzyString = function (str, editDistance) {
1438 var root = new lunr.TokenSet
1457 noEditNode = new lunr.TokenSet
1480 var insertionNode = new lunr.TokenSet
1518 var substitutionNode = new lunr.TokenSet
1544 transposeNode = new lunr.TokenSet
1571 * @returns {lunr.TokenSet}
1573 lunr.TokenSet.fromString = function (str) {
1574 var node = new lunr.TokenSet,
1594 var next = new lunr.TokenSet
1615 lunr.TokenSet.prototype.toArray = function () {
1630 * https://github.com/olivernn/lunr.js/issues/279 Calling any
1660 lunr.TokenSet.prototype.toString = function () {
1694 * @param {lunr.TokenSet} b - An other TokenSet to intersect with.
1695 * @returns {lunr.TokenSet}
1697 lunr.TokenSet.prototype.intersect = function (b) {
1698 var output = new lunr.TokenSet,
1742 next = new lunr.TokenSet
1759 lunr.TokenSet.Builder = function () {
1761 this.root = new lunr.TokenSet
1766 lunr.TokenSet.Builder.prototype.insert = function (word) {
1788 var nextNode = new lunr.TokenSet,
1806 lunr.TokenSet.Builder.prototype.finish = function () {
1810 lunr.TokenSet.Builder.prototype.minimize = function (downTo) {
1829 * lunr.Index
1837 * Usually instances of lunr.Index will not be created using this constructor, instead
1838 * lunr.Builder should be used to construct new indexes, or lunr.Index.load should be
1844 * @param {Object<string, lunr.Vector>} attrs.fieldVectors - Field vectors
1845 * @param {lunr.TokenSet} attrs.tokenSet - An set of all corpus tokens.
1847 * @param {lunr.Pipeline} attrs.pipeline - The pipeline to use for search terms.
1849 lunr.Index = function (attrs) {
1859 * @typedef {Object} lunr.Index~Result
1862 * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match.
1866 * Although lunr provides the ability to create queries using lunr.Query, it also provides a simple
1867 * query language which itself is parsed into an instance of lunr.Query.
1869 * For programmatically building queries it is advised to directly use lunr.Query, the query language
1885 * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term
1900 * @typedef {string} lunr.Index~QueryString
1916 * Performs a search against the index using lunr query syntax.
1922 * For more programmatic querying use lunr.Index#query.
1924 * @param {lunr.Index~QueryString} queryString - A string containing a lunr query.
1925 * @throws {lunr.QueryParseError} If the passed query string cannot be parsed.
1926 * @returns {lunr.Index~Result[]}
1928 lunr.Index.prototype.search = function (queryString) {
1930 var parser = new lunr.QueryParser(queryString, query)
1939 * @callback lunr.Index~queryBuilder
1940 * @param {lunr.Query} query - The query object to build up.
1941 * @this lunr.Query
1945 * Performs a query against the index using the yielded lunr.Query object.
1948 * over lunr.Index#search so as to avoid the additional query parsing overhead.
1957 * @param {lunr.Index~queryBuilder} fn - A function that is used to build the query.
1958 * @returns {lunr.Index~Result[]}
1960 lunr.Index.prototype.query = function (fn) {
1968 var query = new lunr.Query(this.fields),
1981 queryVectors[this.fields[i]] = new lunr.Vector
1997 clauseMatches = lunr.Set.complete
2023 var termTokenSet = lunr.TokenSet.fromClause(clause),
2032 if (expandedTerms.length === 0 && clause.presence === lunr.Query.presence.REQUIRED) {
2035 requiredMatches[field] = lunr.Set.empty
2063 matchingDocumentsSet = new lunr.Set(matchingDocumentRefs)
2070 if (clause.presence == lunr.Query.presence.REQUIRED) {
2074 requiredMatches[field] = lunr.Set.complete
2083 if (clause.presence == lunr.Query.presence.PROHIBITED) {
2085 prohibitedMatches[field] = lunr.Set.empty
2119 * of lunr.MatchData ready to be returned in the query
2123 matchingFieldRef = new lunr.FieldRef (matchingDocumentRef, field),
2128 matchingFields[matchingFieldRef] = new lunr.MatchData (expandedTerm, field, metadata)
2146 if (clause.presence === lunr.Query.presence.REQUIRED) {
2159 var allRequiredMatches = lunr.Set.complete,
2160 allProhibitedMatches = lunr.Set.empty
2193 var fieldRef = lunr.FieldRef.fromString(matchingFieldRef)
2194 matchingFields[matchingFieldRef] = new lunr.MatchData
2207 var fieldRef = lunr.FieldRef.fromString(matchingFieldRefs[i]),
2252 lunr.Index.prototype.toJSON = function () {
2265 version: lunr.version,
2274 * Loads a previously serialized lunr.Index
2276 * @param {Object} serializedIndex - A previously serialized lunr.Index
2277 * @returns {lunr.Index}
2279 lunr.Index.load = function (serializedIndex) {
2285 tokenSetBuilder = new lunr.TokenSet.Builder,
2286 pipeline = lunr.Pipeline.load(serializedIndex.pipeline)
2288 if (serializedIndex.version != lunr.version) {
2289 lunr.utils.warn("Version mismatch when loading serialised index. Current version of lunr '" + lunr.version + "' does not match serialized index '" + serializedIndex.version + "'")
2297 fieldVectors[ref] = new lunr.Vector(elements)
2318 return new lunr.Index(attrs)
2321 * lunr.Builder
2326 * lunr.Builder performs indexing on a set of documents and
2327 * returns instances of lunr.Index ready for querying.
2340 * @property {lunr.tokenizer} tokenizer - Function for splitting strings into tokens for indexing.
2341 * @property {lunr.Pipeline} pipeline - The pipeline performs text processing on tokens before indexing.
2342 * @property {lunr.Pipeline} searchPipeline - A pipeline for processing search terms before querying the index.
2349 lunr.Builder = function () {
2356 this.tokenizer = lunr.tokenizer
2357 this.pipeline = new lunr.Pipeline
2358 this.searchPipeline = new lunr.Pipeline
2378 lunr.Builder.prototype.ref = function (ref) {
2414 lunr.Builder.prototype.field = function (fieldName, attributes) {
2430 lunr.Builder.prototype.b = function (number) {
2447 lunr.Builder.prototype.k1 = function (number) {
2468 lunr.Builder.prototype.add = function (doc, attributes) {
2483 fieldRef = new lunr.FieldRef (docRef, fieldName),
2543 lunr.Builder.prototype.calculateAverageFieldLengths = function () {
2551 var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),
2572 * Builds a vector space model of every document using lunr.Vector
2576 lunr.Builder.prototype.createFieldVectors = function () {
2583 var fieldRef = lunr.FieldRef.fromString(fieldRefs[i]),
2586 fieldVector = new lunr.Vector,
2602 idf = lunr.idf(this.invertedIndex[term], this.documentCount)
2629 * Creates a token set of all tokens in the index using lunr.TokenSet
2633 lunr.Builder.prototype.createTokenSet = function () {
2634 this.tokenSet = lunr.TokenSet.fromArray(
2640 * Builds the index, creating an instance of lunr.Index.
2645 * @returns {lunr.Index}
2647 lunr.Builder.prototype.build = function () {
2652 return new lunr.Index({
2675 lunr.Builder.prototype.use = function (fn) {
2682 * A single instance of lunr.MatchData is returned as part of every
2683 * lunr.Index~Result.
2690 * @see {@link lunr.Index~Result}
2692 lunr.MatchData = function (term, field, metadata) {
2715 * An instance of lunr.MatchData will be created for every term that matches a
2716 * document. However only one instance is required in a lunr.Index~Result. This
2717 * method combines metadata from another instance of lunr.MatchData with this
2720 * @param {lunr.MatchData} otherMatchData - Another instance of match data to merge with this one.
2721 * @see {@link lunr.Index~Result}
2723 lunr.MatchData.prototype.combine = function (otherMatchData) {
2763 lunr.MatchData.prototype.add = function (term, field, metadata) {
2788 * A lunr.Query provides a programmatic way of defining queries to be performed
2789 * against a {@link lunr.Index}.
2791 * Prefer constructing a lunr.Query using the {@link lunr.Index#query} method
2795 * @property {lunr.Query~Clause[]} clauses - An array of query clauses.
2796 * @property {string[]} allFields - An array of all available fields in a lunr.Index.
2798 lunr.Query = function (allFields) {
2816 * @see lunr.Query~Clause
2817 * @see lunr.Query#clause
2818 * @see lunr.Query#term
2820 * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })
2823 * wildcard: lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING
2827 lunr.Query.wildcard = new String ("*")
2828 lunr.Query.wildcard.NONE = 0
2829 lunr.Query.wildcard.LEADING = 1
2830 lunr.Query.wildcard.TRAILING = 2
2837 * @see lunr.Query~Clause
2838 * @see lunr.Query#clause
2839 * @see lunr.Query#term
2841 * query.term('foo', { presence: lunr.Query.presence.REQUIRED })
2843 lunr.Query.presence = {
2863 * A single clause in a {@link lunr.Query} contains a term and details on how to
2864 * match that term against a {@link lunr.Index}.
2866 * @typedef {Object} lunr.Query~Clause
2871 * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended.
2872 * @property {number} [presence=lunr.Query.presence.OPTIONAL] - The terms presence in any matching documents.
2876 * Adds a {@link lunr.Query~Clause} to this query.
2881 * @param {lunr.Query~Clause} clause - The clause to add to this query.
2882 * @see lunr.Query~Clause
2883 * @returns {lunr.Query}
2885 lunr.Query.prototype.clause = function (clause) {
2899 clause.wildcard = lunr.Query.wildcard.NONE
2902 if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) {
2906 if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) {
2911 clause.presence = lunr.Query.presence.OPTIONAL
2926 lunr.Query.prototype.isNegated = function () {
2928 if (this.clauses[i].presence != lunr.Query.presence.PROHIBITED) {
2937 * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause}
2948 * @returns {lunr.Query}
2949 * @see lunr.Query#clause
2950 * @see lunr.Query~Clause
2957 * wildcard: lunr.Query.wildcard.TRAILING
2959 * @example <caption>using lunr.tokenizer to convert a string to tokens before using them as terms</caption>
2960 * query.term(lunr.tokenizer("foo bar"))
2962 lunr.Query.prototype.term = function (term, options) {
2964 term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)
2975 lunr.QueryParseError = function (message, start, end) {
2982 lunr.QueryParseError.prototype = new Error
2983 lunr.QueryLexer = function (str) {
2992 lunr.QueryLexer.prototype.run = function () {
2993 var state = lunr.QueryLexer.lexText
3000 lunr.QueryLexer.prototype.sliceString = function () {
3017 lunr.QueryLexer.prototype.emit = function (type) {
3028 lunr.QueryLexer.prototype.escapeCharacter = function () {
3033 lunr.QueryLexer.prototype.next = function () {
3035 return lunr.QueryLexer.EOS
3043 lunr.QueryLexer.prototype.width = function () {
3047 lunr.QueryLexer.prototype.ignore = function () {
3055 lunr.QueryLexer.prototype.backup = function () {
3059 lunr.QueryLexer.prototype.acceptDigitRun = function () {
3067 if (char != lunr.QueryLexer.EOS) {
3072 lunr.QueryLexer.prototype.more = function () {
3076 lunr.QueryLexer.EOS = 'EOS'
3077 lunr.QueryLexer.FIELD = 'FIELD'
3078 lunr.QueryLexer.TERM = 'TERM'
3079 lunr.QueryLexer.EDIT_DISTANCE = 'EDIT_DISTANCE'
3080 lunr.QueryLexer.BOOST = 'BOOST'
3081 lunr.QueryLexer.PRESENCE = 'PRESENCE'
3083 lunr.QueryLexer.lexField = function (lexer) {
3085 lexer.emit(lunr.QueryLexer.FIELD)
3087 return lunr.QueryLexer.lexText
3090 lunr.QueryLexer.lexTerm = function (lexer) {
3093 lexer.emit(lunr.QueryLexer.TERM)
3099 return lunr.QueryLexer.lexText
3103 lunr.QueryLexer.lexEditDistance = function (lexer) {
3106 lexer.emit(lunr.QueryLexer.EDIT_DISTANCE)
3107 return lunr.QueryLexer.lexText
3110 lunr.QueryLexer.lexBoost = function (lexer) {
3113 lexer.emit(lunr.QueryLexer.BOOST)
3114 return lunr.QueryLexer.lexText
3117 lunr.QueryLexer.lexEOS = function (lexer) {
3119 lexer.emit(lunr.QueryLexer.TERM)
3134 lunr.QueryLexer.termSeparator = lunr.tokenizer.separator
3136 lunr.QueryLexer.lexText = function (lexer) {
3140 if (char == lunr.QueryLexer.EOS) {
3141 return lunr.QueryLexer.lexEOS
3151 return lunr.QueryLexer.lexField
3157 lexer.emit(lunr.QueryLexer.TERM)
3159 return lunr.QueryLexer.lexEditDistance
3165 lexer.emit(lunr.QueryLexer.TERM)
3167 return lunr.QueryLexer.lexBoost
3174 lexer.emit(lunr.QueryLexer.PRESENCE)
3175 return lunr.QueryLexer.lexText
3182 lexer.emit(lunr.QueryLexer.PRESENCE)
3183 return lunr.QueryLexer.lexText
3186 if (char.match(lunr.QueryLexer.termSeparator)) {
3187 return lunr.QueryLexer.lexTerm
3192 lunr.QueryParser = function (str, query) {
3193 this.lexer = new lunr.QueryLexer (str)
3199 lunr.QueryParser.prototype.parse = function () {
3203 var state = lunr.QueryParser.parseClause
3212 lunr.QueryParser.prototype.peekLexeme = function () {
3216 lunr.QueryParser.prototype.consumeLexeme = function () {
3222 lunr.QueryParser.prototype.nextClause = function () {
3228 lunr.QueryParser.parseClause = function (parser) {
3236 case lunr.QueryLexer.PRESENCE:
3237 return lunr.QueryParser.parsePresence
3238 case lunr.QueryLexer.FIELD:
3239 return lunr.QueryParser.parseField
3240 case lunr.QueryLexer.TERM:
3241 return lunr.QueryParser.parseTerm
3249 throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)
3253 lunr.QueryParser.parsePresence = function (parser) {
3262 parser.currentClause.presence = lunr.Query.presence.PROHIBITED
3265 parser.currentClause.presence = lunr.Query.presence.REQUIRED
3269 throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)
3276 throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)
3280 case lunr.QueryLexer.FIELD:
3281 return lunr.QueryParser.parseField
3282 case lunr.QueryLexer.TERM:
3283 return lunr.QueryParser.parseTerm
3286 throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)
3290 lunr.QueryParser.parseField = function (parser) {
3301 throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)
3310 throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)
3314 case lunr.QueryLexer.TERM:
3315 return lunr.QueryParser.parseTerm
3318 throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)
3322 lunr.QueryParser.parseTerm = function (parser) {
3343 case lunr.QueryLexer.TERM:
3345 return lunr.QueryParser.parseTerm
3346 case lunr.QueryLexer.FIELD:
3348 return lunr.QueryParser.parseField
3349 case lunr.QueryLexer.EDIT_DISTANCE:
3350 return lunr.QueryParser.parseEditDistance
3351 case lunr.QueryLexer.BOOST:
3352 return lunr.QueryParser.parseBoost
3353 case lunr.QueryLexer.PRESENCE:
3355 return lunr.QueryParser.parsePresence
3358 throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)
3362 lunr.QueryParser.parseEditDistance = function (parser) {
3373 throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)
3386 case lunr.QueryLexer.TERM:
3388 return lunr.QueryParser.parseTerm
3389 case lunr.QueryLexer.FIELD:
3391 return lunr.QueryParser.parseField
3392 case lunr.QueryLexer.EDIT_DISTANCE:
3393 return lunr.QueryParser.parseEditDistance
3394 case lunr.QueryLexer.BOOST:
3395 return lunr.QueryParser.parseBoost
3396 case lunr.QueryLexer.PRESENCE:
3398 return lunr.QueryParser.parsePresence
3401 throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)
3405 lunr.QueryParser.parseBoost = function (parser) {
3416 throw new lunr.QueryParseError (errorMessage, lexeme.start, lexeme.end)
3429 case lunr.QueryLexer.TERM:
3431 return lunr.QueryParser.parseTerm
3432 case lunr.QueryLexer.FIELD:
3434 return lunr.QueryParser.parseField
3435 case lunr.QueryLexer.EDIT_DISTANCE:
3436 return lunr.QueryParser.parseEditDistance
3437 case lunr.QueryLexer.BOOST:
3438 return lunr.QueryParser.parseBoost
3439 case lunr.QueryLexer.PRESENCE:
3441 return lunr.QueryParser.parsePresence
3444 throw new lunr.QueryParseError (errorMessage, nextLexeme.start, nextLexeme.end)
3465 root.lunr = factory()
3473 return lunr