-
Notifications
You must be signed in to change notification settings - Fork 49
Index configuration
floere edited this page Nov 23, 2010
·
15 revisions
Indexes in Picky hold categorized data.
An index needs:
- A Source
- One or more Categories
In code (using Ruby 1.9 new style hashes):
books_index = index :books, Sources::CSV.new(:title, :author, :isbn, file: 'app/library.csv')
books_index.define_category :title,
similarity: Similarity::Phonetic.new(3),
partial: Partial::Substring.new(from: 1)
This creates a new index (with the index
method), which has a CSV source with (an implicit id) title, author, and isbn.
For the title data we create a category (with the define_category
method). A category has a few options. In the example, we tell Picky to also find phonetically similar results (each indexed word is linked to up to three other indexed, similar words). Also, it will find a title word even if it is only partially matched, so “Hob” will find “Hobbit”.
If you are of the “an image says 1000 words” type, I hope this helps: