"indexes B.content" *should* be valid syntax.
This is just a guess, but it's possible sphinx is failing because your
foreign key and association have the same name. Can you name your
association something else?
Class A < ActiveRecord::Base
belongs_to :not_b, :foreign_key => "B", :class_name => "B"
define_index do
indexes not_b.content, :as => "content"
end
end
-- James Healy <jimmy-at-deefa-dot-com> Mon, 03 Aug 2009 14:49:26 +1000
Maneki Neko wrote:
>
> I have a legacy database I'm working with structured as follows, where
> the name and content for one thing is split into two separate tables:
> A (table)
> :name
> :B (a foreign key)
> B (table)
> :content
>
> I've currently got A indexed by Thinking Sphinx on :name, but I'd like
> to also index on :content. How can I structure things so that a query
> against A will search across both the contents of :content as well
> as :name?
>
> When I just use
> indexes B
> I now have an index of numbers rather than of the actual content
> itself, which isn't too useful for searching.
>
> When I take the direct approach of telling Rails
> belongs_to :B, :foreign_key => :B
> and
> indexes B.content
> that doesn't work with the Sphinx. However, basic Rails functionality
> does work, like being able to go a.b.content to see the content.
>
> Is there any way to do this without having to modify the legacy
> databases themselves?
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---