Hi Matthew

Is the price column for Product a float or an integer? Because Sphinx has no 
concept of arrays of floats (only arrays of integers), so it could be the data 
it's indexing isn't quite correct, hence the odd results.

If it's an integer, then things *should* be working fine, but we can continue 
to work through this issue.

Cheers

-- 
Pat

On 14/12/2010, at 8:00 AM, Matthew Hinton wrote:

> I am having an issue with filtering on an associations attribute. When I run 
> a search I want all the associations attributes to match to return a result.
> 
> class Publication < ActiveRecord::Base
>   belongs_to :imprint
>   has_many :products
>   has_many :subscriptions
>   belongs_to :cover_image
>   belongs_to :edition
> 
>   define_index do
>     indexes [edition.title_prefix,
>              edition.title,
>              edition.subtitle], :as => :title, :sortable => true
>     indexes [edition.work.authorships.authorizable.profile.given_names,
>              edition.work.authorships.authorizable.profile.surname], :as => 
> :author, :sortable => true
>     indexes [edition.short_description,
>              edition.long_description], :as => :description
>     indexes [edition.abstract], :as => :abstract
> 
>     has products.media_type(:id), :as => :mt
>     has products.price, :as => :price
>     has date_published, :as => :date_published
>     has imprint_id, :type => :integer, :as => :imprint
>     has edition.work.work_type(:id), :type => :integer, :as => :pt
>   end
> 
> The following query returns 3 records which is correct. It matches the :mt 
> and :pt attributes correctly.
> 
> Publication.search(nil, :match_mode => :extended, :sort_by => 
> :date_published, :with => { :pt => 3, :mt => 2 })
> 
> However the following query returns 2 records when it shouldn't return any. 
> Each Publication has 2 products in the association. Each of the association 
> results match either the :mt attribute or the :price attribute but not both, 
> one has the correct :mt value but the :price is to high and the other has the 
> wrong :mt value but the :price is within the range. 
> 
> Publication.search(nil, :match_mode => :extended, :sort_by => 
> :date_published, :with => { :pt => 3, :mt => 2, :price => (0..5) })
> 
> Can someone tell me what I am missing? I am using postgresql 8.4 and the 
> latest spinx mac port and the latest thinkingsphinx.
> 
> -- 
> Matthew Hinton
> [email protected]
> http://www.myverbaloutlet.net
> 
> -- 
> 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.

Reply via email to