Firstly: ignoring the warning is fine - it's not too big a deal.
That said, if you're searching across multiple models (STI or otherwise) with
facets, it might be best to have each facet exist in every index. You don't
need to use a column though - for example, you could use the following in your
Vehicle index:
has '0', :as => :number_doors, :type => :integer, :facet => true
Sphinx treats NULLs as 0's, hence why I didn't use NULL. I guess then, though,
you'd need to hide the facet result for 0 number_doors (or use a filter:
:without => {:number_doors => true}).
Maybe the best approach is to just keep the facet query to the car index:
Car.facets(:index => 'car_core', :with => :number_doors => 2}
Avoids the error, avoids the vehicle index, and you get the right results.
--
Pat
On 21/05/2011, at 4:46 PM, yellowpinky wrote:
> Any ideas guys? Any feedback (even of the its a dumb question variety)
> would be great :-)
>
> On May 20, 8:20 am, yellowpinky <[email protected]> wrote:
>> I have an issue with facet visibility in subclasses that are part of a
>> single table inheritance (STI) relationship that I would very much
>> appreciate some help with:
>>
>> Given the below classes:
>>
>> class Vehicle
>> define_index do
>> indexes make,
>> indexes model
>> end
>> end
>>
>> class Car < Vehicle
>> define_index do
>> has number_doors, :facet => true
>> end
>> end
>>
>> class Motorbike < Vehicle
>> define_index do
>> has final_drive, :facet => true
>> end
>> end
>>
>> When I perform a search
>>
>> @cars = Car.search 'Ford'
>> @facets = @cars.facets :with => { :number_doors => '2' }
>>
>> The query runs and the results are displayed BUT a warning is logged:
>>
>> Sphinx Daemon returned warning: index vehicle_core: no such filter
>> attribute 'number_doors'
>>
>> If I move the number_doors attribute to the Vehicle model it is no
>> longer found.
>>
>> If I declare it in both models the error disappears but the facet
>> total is doubled.
>>
>> Is this expected behaviour or am I doing something wrong?
>>
>> As background info I'm using:
>>
>> Rails: 2.3.8
>> TS: 1.4.5
>> Sphinx 0.9.9
>>
>> Any help greatly appreciated!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.