Saturday, 15 June 2013

ruby on rails - Unexpected TOK_IDENT in Sphinx Query -



ruby on rails - Unexpected TOK_IDENT in Sphinx Query -

i'm migrating search logic using basic model scopes , geocoder gem utilize thinking sphinx.

i've migrated logic on fine exception of geosearching logic. when run search next error:

parse error: sphinx expr: syntax error, unexpected tok_ident near 'latitude, longitude)

the query tried run was:

select geodist(0.9037681385969557, 0.08613329012956664, latitude, longitude) geodist, * refinery_marketplaces_business_core match('consultants') , sphinx_deleted = 0 order geodist asc limit 0, 20;

here's relevant extracts:

index definition:

has 'radians(latitude)', :as => :latitude, :type => :float has 'radians(longitude)', :as => :longitude, :type => :float group_by 'latitude', 'longitude' # needed postgresql

controller:

@businesses = business.search params[:keywords], :geo => [0.9037681385969557, 0.08613329012956664], :order => "geodist asc"

the 2 similar posts can find on here are:

https://github.com/pat/thinking-sphinx/issues/648 https://github.com/pat/thinking-sphinx/issues/702

both of result of people calling search on wrong model - i'm calling on right model.

here versions of in play:

ruby 2.0.0p247 rails 3.2.14 thinking sphinx 3.1.1 sphinx 2.1.4 (brew installed) postgres 9.3.2 (brew installed)

update:

i found out can come in sphinxql queries sphinx cli after reading post: connect sphinxql through linux command-line

mysql -p9306 --protocol=tcp --prompt='sphinxql> '

a couple of observations after running this:

removing geodist() references query returns fine running simple select * query shows latitude , longitude aren't in index running \d+ refinery_marketplaces_businesses in psql shows fields on table: latitude | double precision longitude | double precision both fields included in sql_query generated rake ts:rebuild don't show in generated index.

any help hugely appreciated!

thanks

i managed sort including reply else runs error message.

the error: unexpected tok_ident means field referenced in query doesn't exist in index.

the best way verify what's in index run sphinx cli using:

mysql -p9306 --protocol=tcp --prompt='sphinxql> '

and run select * query like:

select * your_index_core sphinx_deleted = 0 limit 0, 20;

from here can see fields in index across top.

i can't figure out why didn't exist in index - i'd ran rake ts:rebuild multiple times no avail. in end had stop searchd, manually delete configuration file , indexes , rebuild scratch.

ruby-on-rails sphinx thinking-sphinx

No comments:

Post a Comment