Skip to content

Index configuration

floere edited this page Nov 23, 2010 · 15 revisions

Picky uses highly categorized data to be able to find out what you’re looking for. This data is all in indexes.

Indexes in Picky hold categorized data. You use Queries to search in these indexes.

An index needs:

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: