Reputation: 2123
I have 3 Rails apps running:
Using Solr on Heroku costs money and I'll be adding it to my production app. I don't want to add Solr to my staging app as performance isn't critical.
I'm wondering if there's a decent way to degrade my Sunspot/Solr calls to SQL queries.
Sunspot calls in my controller look as follows:
@search = Search.find(params[:id])
@results = Listing.search do |query|
query.with(:city).any_of @search.cities if @search.cities
query.with(:county).any_of @search.counties if @search.counties
...
end
Upvotes: 0
Views: 365
Reputation: 566
Additionally, if you're using the WebSolr addon, they actually provide you with two indexes—if you log into the websolr console it will allow you to create a second index there, and you can point to that index from your staging site.
Upvotes: 1
Reputation: 2200
If you're not using Solr's fulltext search, and you're using Rails 2, record_filter has a very similar syntax: https://github.com/aub/record_filter
That said, your best bet would probably be to define two adapter classes that present the same interface but use Solr and SQL under the hood respectively.
Upvotes: 1