Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ lunr.Index.prototype.idf = function (term) {
* @see Index.prototype.documentVector
* @memberOf Index
*/
lunr.Index.prototype.search = function (query) {
lunr.Index.prototype.baseSearch = function (query) {
var queryTokens = this.pipeline.run(this.tokenizerFn(query)),
queryVector = new lunr.Vector,
documentSets = [],
Expand Down Expand Up @@ -382,6 +382,19 @@ lunr.Index.prototype.search = function (query) {
.map(function (ref) {
return { ref: ref, score: queryVector.similarity(this.documentVector(ref)) }
}, this)
}

/**
* Searches the index using the passed query and returns result sorted by score.
*
* @param {String} query The query to search the index with.
* @returns {Object}
* @see Index.prototype.baseSearch
* @memberOf Index
*/
lunr.Index.prototype.search = function (query) {
return this
.search(query)
.sort(function (a, b) {
return b.score - a.score
})
Expand Down