Just found this example:
class Person < ActiveRecord::Base
define_index do
indexes [first_name, last_name], :as => :name
indexes location
end
end
Looks exactly like what I want to do.
On Sep 7, 8:55 am, Greg <[email protected]> wrote:
> I think I have figured out my problem, my User model has a field for
> first_name and a field for last_name, I want to index full_name which
> is a method on the User model which joins them. I am changing indexing
> from acts_as_ferret and forgot that full_name was not a field. What is
> the best approach in this case? The goal is to allow people to search
> the owner field directly, like owner_name: John Doe, I am parsing this
> google style syntax and converting it to @owner_name John Doe... Is it
> possible to do something like this?
>
> On Sep 5, 10:03 am, Pat Allan <[email protected]> wrote:
>
> > Hi Greg
>
> > :class_name on your association definitions will work fine in TS, as
> > should the rest of the code you've described.
>
> > What's the sql_range_query SQL statement from your Sphinx
> > configuration file for that model? And your full define_index block?
>
> > --
> > Pat
>
> > On 04/09/2009, at 6:17 PM, Greg wrote:
>
> > > The error:
>
> > > ERROR: index 'ticket_core': sql_range_query: You have an error in your
> > > SQL syntax; check the manual that corresponds to your MySQL server
> > > version for the right syntax to use near 'AS CHAR) AS `owner_name`,
> > > `tickets`.`id` AS `sphinx_internal_id`, 2416748693 AS ' at line 1
> > > (DSN=mysql://rails:*...@localhost:3306/ticket-dev).
>
> > > In my Ticket Active record class I have this:
>
> > > belongs_to :owner, options = {:class_name => 'User'}
> > > ...
> > > define_index do
> > > ...
> > > indexes owner(:full_name), :as => :owner_name
> > > end
>
> > > Is my use of :class_name of User not supported by Thinking in Sphinx?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---