Quicksilver is great to search using acronyms or shorthand. Where it's not a good fit is searching through lists of keywords.
The basic approach is to compute a score by counting the number of matched characters, add a point if it matches the start of a word, and return 2 raised to the power of the score.
"this is a test".score("test") // 32
This search was calculated as such: 2(4 + 1).
"this is a test".score("is") // 8 "this is a test".score("hi") // 4
Here you can see that a match at the start of a word ranks much higher than in the middle. More examples can be found in the accompanying tests.
your site and use the
score method on a string of keywords. Give it a string
to search for and it will return a score as a float.
Note on Patches/Pull Requests
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don't break it in a future version unintentionally.
- Send me a pull request. Bonus points for topic branches.
Copyright (c) 2010 Larry Marburger. See LICENSE for details.