Pat,

The changes to :source => :query MVAs in 1.1.19 have improved this
situation, but some cases still aren't working the way I expected.
However I'm realising that maybe I need to adust my expectations.

My Edition model habtm Tags. If I use :source => :query to add the tag
ids to my Edition index then I get the result I expected. A query that
returns edition_id and tag_id pairs.

    has tags(:id), :as => :tag_ids, :source => :query
  
    sql_attr_multi = uint tag_ids from query; SELECT 
`editions_tags`.`edition_id` * 12 + 3 AS `id`, `editions_tags`.`tag_id` AS 
`tag_ids` FROM `editions_tags`

If I try to add supplier tags to the Edition index however, I end up
with a source query that returns supplier_id and tag_id pairs.

    has supplier.tags(:id), :as => :tag_ids, :source => :query

    sql_attr_multi = uint tag_ids from query; SELECT 
`suppliers_tags`.`supplier_id` * 12 + 3 AS `id`, `suppliers_tags`.`tag_id` AS 
`tag_ids` FROM `suppliers_tags`

In the second case I was hoping to get edition_ids and tag_ids as well.
The issue is presumably that I'm using :source => :query on a nested
association. Am I barking up the wrong tree?

James


James Healy wrote:
> 
> Sorry Pat, got another one for you :)
> 
> I think :source => :query generates an incorrect config file when the
> attribute being indexed is through a has_and_belongs_to_many association.
> 
> As I understand it, the query should return a list of edition_id, tag_id
> pairs?
> 
> My index definition for my Edition class contains the following
> attribute line:
> 
>   has tags(:id), :as => :tag_ids, :source => :query
> 
> which generates this line in my sphinx config:
> 
>   sql_attr_multi = uint tag_ids from query; SELECT `tags`.`edition_id` * 12 + 
> 0 AS `id`, `tags`.`id` AS `tag_ids` FROM `tags`
> 
> This is close, but my tags table doesn't have an edition_id field. 
> 
> To confuse TS even more, if I try the following line in my edition:
> 
>   has supplier.tags(:id), :as => :tag_ids, :source => :query
> 
> I get this line in my config:
> 
>   sql_attr_multi = uint tag_ids from query; SELECT 
> `tags_suppliers`.`supplier_id` * 12 + 0 AS `id`, `tags_suppliers`.`id` AS 
> `tag_ids` FROM `tags_suppliers`
> 
> The first field should be the edition id, and the second refers to a non
> exiting tags_suppliers.id.
> 
> -- James Healy <jimmy-at-deefa-dot-com>  Wed, 13 May 2009 18:10:59 +1000
> 
> > 

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