I have multiple models setup and I am trying to search through them all. However, some models have specific conditions that need to be satisfied. A basic example of my search:
@search = Sunspot.search [User, Event, Story, Album, Photo] do
any_of do # Return anything that matches any of the scopes in this block
all_of do # Return only those results that match these scopes
with :class, Album # This limits scopes in this block to Album results
with :private, false
end
end
fulltext params[:q]
with :deleted_at, nil
order_by :created_at, :desc
end
In this example, I am trying to only show albums that are not private. This however doesn't work, nothing is returning. When I removed the any_of block, results return.
I referenced: Querying multiple models with different attributes using Sunspot
Similar issue: Searching across multiple models using sunspot/solr
Any help would be appreciated.