I've got a model that I'm trying to index like this:

class Listing < ActiveRecord::Base
  has_many :listing_images

  define_index do
    # ...
    has "COUNT(listing_images.id) > 0", :as => :has_images, :type
=> :boolean
    # ...
  end
end

Note that I'm not using the listing_images association anywhere else
in this index.  When I run rebuild my index, I get this error:

ERROR: index 'listing_delta': sql_range_query: Unknown column
'listing_images.id' in 'field list'

This makes sense, since the listing_images table wasn't included as a
join in the generated SQL.  I've gotten it to work by adding another
attribute that uses the listing_images association, like so:

has listing_images(:id), :as => :listing_image_id

However, I'm not happy with this solution since I really don't care to
index the listing_image id's.  This attribute exists just to force TS
to include listing_images as a join in the generated SQL.

Is there a simpler, more elegant way to get TS to include
listing_images as a join, without having to define another attribute
for it?

Thanks!
Myron

--~--~---------~--~----~------------~-------~--~----~
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