Browse Source

lunr.js update to 0.2.2

pull/160/head
Simon Waldherr 12 years ago
parent
commit
e0f1088c44
  1. 21
      dist/ratchet.js
  2. 22
      lib/js/lunr.js
  3. 2
      submodules/lunrjs

21
dist/ratchet.js vendored

@ -765,7 +765,7 @@
}(); }();
/* ---------------------------------- /* ----------------------------------
* lunr v0.2.1 * lunr v0.2.2
* http://lunrjs.com - A bit like Solr, but much smaller and not as bright * http://lunrjs.com - A bit like Solr, but much smaller and not as bright
* Copyright (C) 2013 Oliver Nightingale * Copyright (C) 2013 Oliver Nightingale
* Licensed under The MIT License * Licensed under The MIT License
@ -782,7 +782,7 @@ var lunr = function (config) {
return idx return idx
} }
lunr.version = "0.2.1" lunr.version = "0.2.2"
if (typeof module !== 'undefined') { if (typeof module !== 'undefined') {
module.exports = lunr module.exports = lunr
@ -962,17 +962,17 @@ lunr.SortedSet.prototype.intersect = function (otherSet) {
intersectSet.add(a[i]); intersectSet.add(a[i]);
i++; i++;
j++; j++;
continue continue;
} }
if (a[i] < b[j]) { if (a[i] < b[j]) {
i++ i++;
continue continue;
} }
if (a[i] > b[j]) { if (a[i] > b[j]) {
j++ j++;
continue continue;
} }
}; };
@ -1102,10 +1102,15 @@ lunr.Index.prototype.search = function (query) {
var set = this.tokenStore.expand(token).reduce(function (memo, key) { var set = this.tokenStore.expand(token).reduce(function (memo, key) {
var pos = self.corpusTokens.indexOf(key), var pos = self.corpusTokens.indexOf(key),
idf = self.idf(key), idf = self.idf(key),
exactMatchBoost = (key === token ? 10 : 1),
set = new lunr.SortedSet 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) }) Object.keys(self.tokenStore.get(key)).forEach(function (ref) { set.add(ref) })
return memo.union(set) return memo.union(set)

22
lib/js/lunr.js

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

2
submodules/lunrjs

@ -1 +1 @@
Subproject commit 5bcfe579a8fe72dab7fbb1f179e9ca0d5ea6df6d Subproject commit 269e4ad5b66d8481f9fce67ec485f1f4a09ffc4e
Loading…
Cancel
Save