Unfortunately Sphinx doesn't say which field matched the query tokens,
it just returns the fields in the indexes that have been searched
upon. In your situation below, that would be 'name', 'street_address',
'city', 'country', 'postal_code', 'business_description'.
If you wanted that - although it's not particularly useful - you can
get it like so:
Contact.search("burlas").results[:fields]
The results hash is *all* the information Sphinx supplies to Riddle/
Thinking Sphinx.
--
Pat
On 26/02/2009, at 10:12 AM, smbaiges wrote:
>
> Hi all I am having problems retrieving the associated fields that
> caused some objets to be retrieved. I would really appreciate some
> guidance. Until I don't resolve this issue I cant move ahead in my
> project.
>
> Hi have two models and look like this.
>
> class Contact < ActiveRecord::Base
>
> has_many :businesses
>
> define_index do
> indexes [first_name, last_name], :as => :name, :sortable => true
> indexes street_address, city, country, postal_code
> indexes [businesses.name, businesses.description], :as
> => :business_description
> has state_id
> end
>
> end
>
> class Business < ActiveRecord::Base
> belongs_to :contact
> end
>
> When I search for a term I know is in the business name related to
> that contact. I get the Contact object back associated with that
> business. However, I need to have access to the field that caused the
> matched in order to be able to excerpt it. This is what happens when I
> run the search:
>
>>> Contact.search "burlas"
> => [#<Contact id: 2, first_name: "Aaliyah", last_name: "Allen",
> street_address: "71 Murphy Street", city: "Wyola West", country:
> "Australia", postal_code: "6407", created_at: "2009-02-24 20:07:07",
> updated_at: "2009-02-25 02:09:15", state_id: 2>]
>
>
> How can I know that is bussinesses.name that caused the match???
>
> Thanks
>
> s.
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---