Lines Matching refs:term

316  * @param {object} posting - The posting for a given term
323 if (fieldName == '_index') continue // Ignore the term index, its not a field
1410 * @param {string} clause.term - The query clause term.
1411 * @param {number} [clause.editDistance] - The optional edit distance for the term.
1416 return lunr.TokenSet.fromFuzzyString(clause.term, clause.editDistance)
1418 return lunr.TokenSet.fromString(clause.term)
1843 * @param {Object} attrs.invertedIndex - An index of term/field to document reference.
1862 * @property {lunr.MatchData} matchData - Contains metadata about this match including which term(s) caused the match.
1872 * At its simplest queries can just be a single term, e.g. `hello`, multiple terms are also supported
1877 * be inserted anywhere within the term, and more than one wildcard can exist in a single term. Adding
1879 * impact on query performance, especially with wildcards at the beginning of a term.
1881 * Terms can be restricted to specific fields, e.g. `title:hello`, only documents with the term
1885 * Modifiers can also be added to terms, lunr supports edit distance and boost modifiers on terms. A term
1886 * boost will make documents matching that term score higher, e.g. `foo^5`. Edit distance is also supported
1890 * Each term also supports a presence modifier. By default a term's presence in document is optional, however
1891 * this can be changed to either required or prohibited. For a term's presence to be required in a document the
1892 * term should be prefixed with a '+', e.g. `+foo bar` is a search for documents that must contain 'foo' and
1897 * characters that would normally be considered modifiers, e.g. `foo\~2` will search for a term "foo~2" instead
1898 * of attempting to apply a boost of 2 to the search term "foo".
1901 * @example <caption>Simple single term query</caption>
1903 * @example <caption>Multiple term query</caption>
1905 * @example <caption>term scoped to a field</caption>
1907 * @example <caption>term with a boost of 10</caption>
1909 * @example <caption>term with an edit distance of 2</caption>
1988 * Unless the pipeline has been disabled for this term, which is
1990 * term through the search pipeline. A pipeline returns an array
1992 * term, which means we may end up performing multiple index lookups
1993 * for a single query term.
2000 terms = this.pipeline.runString(clause.term, {
2004 terms = [clause.term]
2008 var term = terms[m]
2011 * Each term returned from the pipeline needs to use the same query
2014 * its term property.
2016 clause.term = term
2019 * From the term in the clause we create a token set which will then
2027 * If a term marked as required does not exist in the tokenSet it is
2043 * For each term get the posting and termIndex, this is required for
2052 * For each field that this query term is scoped by (by default
2054 * that have this term in that field.
2057 * term from above.
2066 * if the presence of this term is required ensure that the matching
2079 * if the presence of this term is prohibited ensure that the matching
2100 * the term and a unit value with the appropriate boost applied.
2102 * for the term we are working with. In that case we just add the scores
2108 * If we've already seen this term, field combo then we've already collected
2117 * All metadata for this term/field/document triple
2142 * We do this after all fields for the term have collected their matches because
2255 .map(function (term) {
2256 return [term, this.invertedIndex[term]]
2302 term = tuple[0],
2305 tokenSetBuilder.insert(term)
2306 invertedIndex[term] = posting
2338 * @property {object} documentTermFrequencies - Keeps track of document term frequencies.
2345 * @property {number} _k1 - A parameter to control how quickly an increase in term frequency results in term frequency saturation, the default value is 1.2.
2346 * @property {number} termIndex - A counter incremented for each unique term, used to identify a terms position in the vector space.
2441 * A parameter that controls the speed at which a rise in term frequency results in term
2492 // calculate term frequencies for this field
2494 var term = terms[j]
2496 if (fieldTerms[term] == undefined) {
2497 fieldTerms[term] = 0
2500 fieldTerms[term] += 1
2504 if (this.invertedIndex[term] == undefined) {
2513 this.invertedIndex[term] = posting
2516 // add an entry for this term/fieldName/docRef to the invertedIndex
2517 if (this.invertedIndex[term][fieldName][docRef] == undefined) {
2518 this.invertedIndex[term][fieldName][docRef] = Object.create(null)
2525 metadata = term.metadata[metadataKey]
2527 if (this.invertedIndex[term][fieldName][docRef][metadataKey] == undefined) {
2528 this.invertedIndex[term][fieldName][docRef][metadataKey] = []
2531 this.invertedIndex[term][fieldName][docRef][metadataKey].push(metadata)
2596 var term = terms[j],
2597 tf = termFrequencies[term],
2598 termIndex = this.invertedIndex[term]._index,
2601 if (termIdfCache[term] === undefined) {
2602 idf = lunr.idf(this.invertedIndex[term], this.documentCount)
2603 termIdfCache[term] = idf
2605 idf = termIdfCache[term]
2686 * @param {string} term - The term this match data is associated with
2687 * @param {string} field - The field in which the term was found
2688 * @param {object} metadata - The metadata recorded about this term in this field
2692 lunr.MatchData = function (term, field, metadata) {
2708 if (term !== undefined) {
2709 this.metadata[term] = Object.create(null)
2710 this.metadata[term][field] = clonedMetadata
2715 * An instance of lunr.MatchData will be created for every term that matches a
2727 var term = terms[i],
2728 fields = Object.keys(otherMatchData.metadata[term])
2730 if (this.metadata[term] == undefined) {
2731 this.metadata[term] = Object.create(null)
2736 keys = Object.keys(otherMatchData.metadata[term][field])
2738 if (this.metadata[term][field] == undefined) {
2739 this.metadata[term][field] = Object.create(null)
2745 if (this.metadata[term][field][key] == undefined) {
2746 this.metadata[term][field][key] = otherMatchData.metadata[term][field][key]
2748 this.metadata[term][field][key] = this.metadata[term][field][key].concat(otherMatchData.metadata[term][field][key])
2757 * Add metadata for a term/field pair to this instance of match data.
2759 * @param {string} term - The term this match data is associated with
2760 * @param {string} field - The field in which the term was found
2761 * @param {object} metadata - The metadata recorded about this term in this field
2763 lunr.MatchData.prototype.add = function (term, field, metadata) {
2764 if (!(term in this.metadata)) {
2765 this.metadata[term] = Object.create(null)
2766 this.metadata[term][field] = metadata
2770 if (!(field in this.metadata[term])) {
2771 this.metadata[term][field] = metadata
2780 if (key in this.metadata[term][field]) {
2781 this.metadata[term][field][key] = this.metadata[term][field][key].concat(metadata[key])
2783 this.metadata[term][field][key] = metadata[key]
2806 * This allows wildcards to be added to the beginning and end of a term without having to manually do any string
2813 * @property {number} wildcard.NONE - The term will have no wildcards inserted, this is the default behaviour
2814 * @property {number} wildcard.LEADING - Prepend the term with a wildcard, unless a leading wildcard already exists
2815 * @property {number} wildcard.TRAILING - Append a wildcard to the term, unless a trailing wildcard already exists
2818 * @see lunr.Query#term
2819 * @example <caption>query term with trailing wildcard</caption>
2820 * query.term('foo', { wildcard: lunr.Query.wildcard.TRAILING })
2821 * @example <caption>query term with leading and trailing wildcard</caption>
2822 * query.term('foo', {
2833 * Constants for indicating what kind of presence a term must have in matching documents.
2839 * @see lunr.Query#term
2840 * @example <caption>query term with required presence</caption>
2841 * query.term('foo', { presence: lunr.Query.presence.REQUIRED })
2851 * this term will not be returned.
2857 * this term will not be returned.
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}.
2869 * @property {number} [editDistance] - Whether the term should have fuzzy matching applied, and how fuzzy the match should be.
2870 * @property {boolean} [usePipeline] - Whether the term should be passed through the search pipeline.
2871 * @property {number} [wildcard=lunr.Query.wildcard.NONE] - Whether the term should have wildcards appended or prepended.
2902 if ((clause.wildcard & lunr.Query.wildcard.LEADING) && (clause.term.charAt(0) != lunr.Query.wildcard)) {
2903 clause.term = "*" + clause.term
2906 if ((clause.wildcard & lunr.Query.wildcard.TRAILING) && (clause.term.slice(-1) != lunr.Query.wildcard)) {
2907 clause.term = "" + clause.term + "*"
2937 * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause}
2940 * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion
2943 * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an
2944 * array, each term in the array will share the same options.
2946 * @param {object|object[]} term - The term(s) to add to the query.
2951 * @example <caption>adding a single term to a query</caption>
2952 * query.term("foo")
2953 * @example <caption>adding a single term to a query and specifying search fields, term boost and automatic trailing wildcard</caption>
2954 * query.term("foo", {
2960 * query.term(lunr.tokenizer("foo bar"))
2962 lunr.Query.prototype.term = function (term, options) {
2963 if (Array.isArray(term)) {
2964 term.forEach(function (t) { this.term(t, lunr.utils.clone(options)) }, this)
2969 clause.term = term.toString()
3170 // "+" indicates term presence is required
3178 // "-" indicates term presence is prohibited
3243 var errorMessage = "expected either a field or a term, found " + lexeme.type
3275 var errorMessage = "expecting term or field, found nothing"
3285 var errorMessage = "expecting term or field, found '" + nextLexeme.type + "'"
3309 var errorMessage = "expecting term, found nothing"
3317 var errorMessage = "expecting term, found '" + nextLexeme.type + "'"
3329 parser.currentClause.term = lexeme.str.toLowerCase()