-
Notifications
You must be signed in to change notification settings - Fork 49
Sources Configuration
Sources tell an index where to get its data.
Example
Possible Sources
Database
CSV
Delicious
Experimental
The method index(identifier_symbol, source, *categories, options = {}) takes a source as second argument.
class PickySearch < Application
books_index = index :books,
Sources::CSV.new(:title, :author, :isbn, :year, :publisher, :subjects, :file => 'app/library.csv'),
category(:title, # ...
end
The source defines where this index is getting its data from.
Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml')
Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', active_records_configuration_options_hash)
You can use join statements etc. (The :file option points to a yml with an active record config hash)
Then, reference your columns by their names in the catgories:
Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'),
category(:isbn),
category(:title), # ...
Sources::CSV.new(:title, :author, :isbn, :year, :publisher, :subjects, :file => 'app/library.csv')
The first column in the CSV needs to be the id. The others are assumed to be in the order you provide.
Sources::Delicious.new('username', 'password')
Delicious then provides a selection of categories: title, tags, url.
Sources::Couch.new(:title, :author, :isbn, :year, :publisher, :subjects, {:url => 'http://localhost:5984/library', :user => 'user', :password => 'password'})
TODO:
- Get mapped/filtered documents,
- add picky-client example with documents retrieving
If needed you can provide each category with its own source.
Sources::DB.new('SELECT id, title, author, isbn13 as isbn FROM books', :file => 'app/db.yml'),
category(:isbn, :source => Sources::CSV.new(:isbn, :file => 'app/isbn.csv')),
category(:title, :source => Sources::Delicious.new('username', 'password')), # ...
But normally you won’t need this. Don’t hesitate to ask if you don’t see any other possibility than using this.