Created
May 18, 2012 16:33
-
-
Save valakirka/2726260 to your computer and use it in GitHub Desktop.
Indexes and custom sphinx_select searches
This file contains hidden or 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
class NewsEntry < AR::Base | |
has_one :association | |
define_index do | |
index wadus | |
has association.published_at, :as => :published_at | |
end | |
end | |
class WadusController < AC | |
def index | |
# Here I'd like to use my defined filter attribute, but seems like it's | |
# using the regular 'published_at' attribute of NewsEntry. Is that possible? | |
published_conditions = "*, if((published_at > NOW() OR published_at = 0), 0, 1) as published" | |
conditions = {:sphinx_select => published_conditions, | |
:with => {:published => 1}} | |
@collection = ThinkingSphinx.search(conditions) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment