diff --git a/lib/index.js b/lib/index.js index 1e4dbac0..83bc5471 100644 --- a/lib/index.js +++ b/lib/index.js @@ -151,11 +151,15 @@ lunr.Index.prototype.add = function (doc, emitEvent) { var fieldTokens = this.pipeline.run(lunr.tokenizer(doc[field.name])) docTokens[field.name] = fieldTokens - lunr.SortedSet.prototype.add.apply(allDocumentTokens, fieldTokens) + + for (var i = 0; i < fieldTokens.length; i++) { + var token = fieldTokens[i] + allDocumentTokens.add(token) + this.corpusTokens.add(token) + } }, this) this.documentStore.set(docRef, allDocumentTokens) - lunr.SortedSet.prototype.add.apply(this.corpusTokens, allDocumentTokens.toArray()) for (var i = 0; i < allDocumentTokens.length; i++) { var token = allDocumentTokens.elements[i] diff --git a/lib/sorted_set.js b/lib/sorted_set.js index 2f0cd6d2..a8422940 100644 --- a/lib/sorted_set.js +++ b/lib/sorted_set.js @@ -224,7 +224,9 @@ lunr.SortedSet.prototype.union = function (otherSet) { unionSet = longSet.clone() - unionSet.add.apply(unionSet, shortSet.toArray()) + for(var i = 0, shortSetElements = shortSet.toArray(); i < shortSetElements.length; i++){ + unionSet.add(shortSetElements[i]) + } return unionSet }