Improve ranking of search results when multiple exact matches are found

pull/110/head
Thibaut 11 years ago
parent ec0e9f0b44
commit 115ffa8fc8

@ -135,6 +135,7 @@ class app.Searcher
#
index = # position of the query in the string being matched
lastIndex = # last position of the query in the string being matched
match = # regexp match data
score = # score for the current match
separators = # counter
@ -144,6 +145,14 @@ class app.Searcher
index = value.indexOf @query
return unless index >= 0
lastIndex = value.lastIndexOf @query
if index isnt lastIndex
Math.max(@scoreExactMatch(value, index), @scoreExactMatch(value, lastIndex))
else
@scoreExactMatch(value, index)
scoreExactMatch: (value, index) ->
# Remove one point for each unmatched character.
score = 100 - (value.length - @queryLength)

Loading…
Cancel
Save