This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
mkristian (author)
Wed Mar 11 05:00:17 -0700 2009
kristians_rails_plugins / act_as_fuzzy_search
| name | age | message | |
|---|---|---|---|
| .. | |||
| |
MIT-LICENSE | ||
| |
MIT-LICENSE~ | ||
| |
README | ||
| |
README~ | ||
| |
Rakefile | ||
| |
init.rb | Mon Dec 15 03:33:15 -0800 2008 | |
| |
init.rb~ | ||
| |
install.rb | ||
| |
lib/ | Mon Dec 15 03:40:33 -0800 2008 | |
| |
tasks/ | Mon Dec 15 03:40:33 -0800 2008 | |
| |
test/ | Mon Dec 15 03:40:33 -0800 2008 | |
| |
uninstall.rb |
act_as_fuzzy_search/README
ActAsFuzzySearch ================ this plugin is inspired by the following blog entry http://unirec.blogspot.com/2007/12/live-fuzzy-search-using-n-grams-in.html it can add a fuzzy search to model. this search needs another table where all the trigrams are stored but that table is hidden otherwise. the whole plugins does not work with ActiveRecords, but for Datamapper !! to get it to work for ActiveRecord only a few code places need to be changed, I marked the in the code #DM. configuration ============= add the following in the model class include FuzzySearch act_as_fuzzy_search :property1, :property1 where :property1, :property2 are the properties which are index for the fuzzy search. each property gets split into words (separator is the whitespaces) if you define a methods returning a string def self.normalize(word) before include the FuzzySearch than this method gets used to normlize any word. default is to downcast the string (which does only work properly within ascii) trigrams table ============== the naming follows the convention class <model_classname>Trigram property :id, Integer, :serial => true property :<model_lowercase>_id, Integer, :index => true property :token, String, :nullable => false, :length => 3, :index => true end example ======= class UserTrigram include DataMapper::Resource property :id, Integer, :serial => true property :user_id, Integer, :index => true property :token, String, :nullable => false, :length => 3, :index => true end the model class looks like this class User include DataMapper::Resource def self.normalize(word) #TODO something word.downcase end include FuzzySearch act_as_fuzzy_search :firstname, :surname property :id, Integer, :serial => true property :surname, String, :nullable => false , :format => /^[^<'&">]*$/, :length => 32 property :firstname, String, :nullable => false , :format => /^[^<'&">]*$/, :length => 32 end now you can create users and search them in a fuzzy manner like User.fuzzy_find("Heywy") enjoy !! Copyright (c) 2008 kristian, released under the MIT license








