Hi
I have 3 models (Rails) defined like so:
class ModelA
belongs_to :model_b
searchable do
integer :model_b_id
end
end
class ModelB
has_many :model_a
has_many :model_c
end
class ModelC
belongs_to :model_b
#has attributes: attr1
searchable do
integer :attr1
end
end
I'm trying to search ModelA, but using ModelB#id and ModelC#attr1. I tried to do 2 joins (ModelB being in the middle), but it didn't work:
class ModelB
searchable do
join(:attr1, target: ModelC, type: :integer,
join: {from: :model_c_id, to: :id})
end
end
class ModelA
searchable do
join(:attr1, target: ModelB, type: :integer,
join: {from: :id, to: :model_b_id})
end
end
ModelA.search do
with(:model_b_id, 10)
with(:attr1, 5) #this should search through ModelB and then ModelC
end
Is this possible with Sunspot/Sorl?
Possible workaround: I think I will have to index ModelC's data at least in ModelB and make a regular join. Or even index the data directly in ModelA.
---
Best
Bartek