|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/* ---------------------------------- |
|
|
|
|
* lunr v0.2.1 |
|
|
|
|
* lunr v0.2.2 |
|
|
|
|
* http://lunrjs.com - A bit like Solr, but much smaller and not as bright
|
|
|
|
|
* Copyright (C) 2013 Oliver Nightingale |
|
|
|
|
* Licensed under The MIT License |
|
|
|
@ -16,7 +16,7 @@ var lunr = function (config) {
|
|
|
|
|
return idx |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
lunr.version = "0.2.1" |
|
|
|
|
lunr.version = "0.2.2" |
|
|
|
|
|
|
|
|
|
if (typeof module !== 'undefined') { |
|
|
|
|
module.exports = lunr |
|
|
|
@ -370,9 +370,8 @@ lunr.SortedSet.prototype.intersect = function (otherSet) {
|
|
|
|
|
if (i > a_len - 1 || j > b_len - 1) break |
|
|
|
|
|
|
|
|
|
if (a[i] === b[j]) { |
|
|
|
|
intersectSet.add(a[i]); |
|
|
|
|
i++;
|
|
|
|
|
j++; |
|
|
|
|
intersectSet.add(a[i]) |
|
|
|
|
i++, j++ |
|
|
|
|
continue |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -417,11 +416,9 @@ lunr.SortedSet.prototype.union = function (otherSet) {
|
|
|
|
|
var longSet, shortSet, unionSet |
|
|
|
|
|
|
|
|
|
if (this.length >= otherSet.length) { |
|
|
|
|
longSet = this;
|
|
|
|
|
shortSet = otherSet; |
|
|
|
|
longSet = this, shortSet = otherSet |
|
|
|
|
} else { |
|
|
|
|
longSet = otherSet; |
|
|
|
|
shortSet = this; |
|
|
|
|
longSet = otherSet, shortSet = this |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
unionSet = longSet.clone() |
|
|
|
@ -633,10 +630,15 @@ lunr.Index.prototype.search = function (query) {
|
|
|
|
|
var set = this.tokenStore.expand(token).reduce(function (memo, key) { |
|
|
|
|
var pos = self.corpusTokens.indexOf(key), |
|
|
|
|
idf = self.idf(key), |
|
|
|
|
exactMatchBoost = (key === token ? 10 : 1), |
|
|
|
|
set = new lunr.SortedSet |
|
|
|
|
|
|
|
|
|
if (pos > -1) queryArr[pos] = tf * idf |
|
|
|
|
// calculate the query tf-idf score for this token
|
|
|
|
|
// applying an exactMatchBoost to ensure these rank
|
|
|
|
|
// higher than expanded terms
|
|
|
|
|
if (pos > -1) queryArr[pos] = tf * idf * exactMatchBoost |
|
|
|
|
|
|
|
|
|
// add all the documents that have this key into a set
|
|
|
|
|
Object.keys(self.tokenStore.get(key)).forEach(function (ref) { set.add(ref) }) |
|
|
|
|
|
|
|
|
|
return memo.union(set) |
|
|
|
|