Hi Erik
If you want to limit certain terms to specific fields, you can do it
as follows:
DealerAccount.search :conditions => {:makes_name => "*#{value}*"},
:order => :dealership_name,
:sort_mode => :desc
Your define_index block seems to be correct - as long as you use the
association names, Thinking Sphinx should understand what you mean.
Cheers
--
Pat
On 13/01/2009, at 1:08 PM, elanderholm wrote:
>
> I'm new to thinking_sphinx and am loving it, but am confused on when
> to use indexes, attributes, and how to access them.
>
> I have a makes table and an accounts table. Each has a
> has_and_belongs_to_many relationship with each other.
>
> I am using an accounts_makes table to join the two tables. What i
> want to to is search the accounts by name and the makes.name field
> also.
>
> I have indexes for the accounts table that look like this:
> define_index do
> indexes dealership_name, :sortable => true
> indexes dealership_zip
> indexes makes.name, :as => :makes_name
> set_property :enable_star => true
> set_property :min_infix_len => 3
>
> end
>
> I can search my accounts by by dealership_name and zip code just fine
> by doing something like this:
> @dealers = DealerAccount.search "*#{value}*", :order
> => :dealership_name, :sort_mode => :desc
>
> How can also search by the makes_name that each dealership account may
> have through the join table? makes table has name as column that is
> something like 'honda'.
>
> Each account may have up to 5 or more makes joined by the
> accounts_makes table.
>
> This is probably pretty basic, but I'm having some problems. Any help
> would be great.
>
> Thanks.
> Erik
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---