Created
February 13, 2009 00:44
-
-
Save bkeepers/62972 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Thoughts on a backend-agnostic search plugin | |
Scour.define Model do | |
backend :ferret # or :sphinx / :solr | |
index title, :sortable => true, :boost => 1.0 | |
index content, author_id, created_at, updated_at | |
index author.name, :as => :author, :sortable => true | |
index first_name, last_name, :as => [:name, :fullname] | |
index tags.name, :as => :tags | |
index minor { author.age < 18 } | |
where { active? } | |
boost votes.count | |
age 3.days | |
end | |
Scour.define 'multi' do | |
backend :ferret | |
with Foo do | |
index name | |
end | |
with Bar do | |
index thing | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# AR style | |
Model.search(:conditions => {:title => 'foo', :created_at => 1.week.ago..Time.now}) | |
# Freeform | |
Model.search('foo', :order => :title) | |
# specific index | |
Scour['multi'].search('…') | |
# or | |
Scour.search '…', :in => 'multi' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment