Hi Ken-ichi
If you can't get it into an actual association (instead of a
named_scope), then your best approach is to have a manual SQL MVA, as
you've been thinking.
has FEATURE_OPTION_IDS_SQL,
:as => :feature_option_ids,
:source => :query
However, as discussed previously on this list, there is a caveat - you
need to make sure you're generating the offset correctly for the IDs.
Have a look at the following threads:
http://groups.google.com/group/thinking-sphinx/browse_thread/thread/94bec92a0c401136
http://groups.google.com/group/thinking-sphinx/browse_thread/thread/2b4dc2cf91f4976c
Hope this helps
Cheers
--
Pat
On 12/04/2009, at 4:04 PM, Ken-ichi wrote:
>
> Hi all,
>
> Is there a way to index the results of an arbitrary SQL query as an
> MVA? I'm trying to index the ancestor ids of records in a table that
> implements nested sets, and I want to index something like
>
> SELECT id FROM `taxa` WHERE (taxa.`lft` <= 5691 AND taxa.`rgt` >=
> 5692) ORDER BY `lft`
>
> for each record, but I'm not sure how. My best attempt was
>
> has "(SELECT id FROM `taxa` WHERE (taxa.`lft` <= lft AND taxa.`rgt` >=
> rgt) ORDER BY `lft`)", :as => :self_and_ancestors_ids, :type => :multi
>
> but that just creates invalid SQL (Subquery returns more than 1 row).
> I'm using the awesome_nested_set Rails plugin, which wraps these
> queries in named scopes, so I also tried
>
> has self_and_ancestors(:id), :as => :self_and_ancestors_ids, :type
> => :multi
>
> but it only seems to index the id of the current record, not itself
> and all its ancestors.
>
> Anyone have any ideas on how I can index these ancestor IDs?
>
> -Ken-ichi
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---