class Cat < ActiveRecord::Base
searchable do
string :color
end
end
class Dog < ActiveRecord::Base
searchable do
string :color
end
end
Given the models Cat
and Dog
above, how do I do a sunspot search for All dogs + only cats that are brown.
|dogs|color| |cats|color|
------------ ------------
| 1 |black| | 1 |black|
| 2 |brown| | 2 |brown|
| 3 | red | | 3 | red |
With the above dogs/cats, I want Dogs [1, 2 3]
and Cat [2]
.
I want something like below, but condition the with
to only apply to Cats
.
Sunspot.search(Dog, Cat) do
with :color, "brown"
end
Is there a with
parameter that is the model type? If so I could do something like this:
Sunspot.search(Dog, Cat) do
any_of do
with :color, "brown"
with :model, Dog
end
end
How do you scope the Sunspot DSL pieces around a model being searched for?