I did the has and belongs to since what I was using before didn't seem to
work. I now changed it back to `belongs_to :locations`. Regardless with
your code the new error I get is…`undefined local variable or method
`latitude' for main:Object`
It's reading latitude instead of the form lat because I just renamed the
columns fyi.
BTW previously before I
On Thursday, November 21, 2013 4:00:00 PM UTC-5, Pat Allan wrote:
>
> There are two problems with your index definition, and both are because
> you have many zip values for a given user.
>
> Sphinx does not allow for multi-value string attributes (only integers or
> timestamps), and it only accepts a single pair of lat/lng values for a
> record, not many.
>
> It may be worth searching on zips instead, and then viewing the users from
> those zips?
>
> ThinkingSphinx::Index.define :zip, :with => :active_record do
> indexes city
>
> has “RADIANS(zips.lat)”, :as => :latitude, :type => :float
> has “RADIANS(zips.lon)”, :as => :longitude, :type => :float
> end
>
> ThinkingSphinx::Index.define :user, :with => :active_record do
> indexes name, :as => :user, :sortable => true
> indexes religion, zip_code, about_me, career, sexuality, children,
> user_smoke, user_drink, gender, ethnicity, education
>
> has created_at, updated_at
> has zips.ids, :as => :zip_ids
> end
>
> zip_ids = Zip.search_for_ids :geo => [lat, lng], :with => {:geodist =>
> 0.0..10_000.0}
> users = User.search ‘foo’, :with => {:zip_ids => zip_ids}
>
> Hope this helps.
>
> —
> Pat
>
> On 22 Nov 2013, at 7:19 am, C Wilson <[email protected] <javascript:>>
> wrote:
>
> > I am not sure what to do with fixing this. I get the error when
> reindexing: ERROR: index 'user_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 '.zip AS `zip_city`,
> RADIANS(zips.lat) AS `latitude`, RADIANS(zips.lon) AS `longi' at line 1
> >
> > Any idea on how to fix? I was joining the Zips table to the Users table.
> I used a has_and_belongs_to_many association in the Zips and Users models.
> >
> > ThinkingSphinx::Index.define :user, :with => :active_record do
> > # fields
> > indexes name, :as => :user, :sortable => true
> > indexes religion, zip_code, about_me, career, sexuality, children,
> user_smoke, user_drink, gender, ethnicity, education
> >
> > # attributes
> > has id, created_at, updated_at
> > has "(ZIP)zips.city", :as => :zip_city, :type => :integer
> >
> > has "RADIANS(zips.lat)", :as => :latitude, :type => :float
> > has "RADIANS(zips.lon)", :as => :longitude, :type => :float
> > end
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Thinking Sphinx" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected] <javascript:>.
> > To post to this group, send email to
> > [email protected]<javascript:>.
>
> > Visit this group at http://groups.google.com/group/thinking-sphinx.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.