Sphinxql: syntax error, unexpected IDENT

Getting this error using sphinx 2

sphinxql: syntax error, unexpected IDENT, expecting CONST_INT or CONST_FLOAT or '-' near 'WI AND published = 1 AND sphinx_deleted = 0 LIMIT 0, 10; SHOW META' 

index.html.erb

an error occurs in the template in the partial collection line: @posts_by_state, but two other instances of the same particle work fine. State sorting is what discards it.

posts_controller.rb

 @posts_by_state = Post.search(params[:search], with: { state: current_user.state, published: true }, :page => params[:page], :per_page => 10) 

post_index.rb

 ThinkingSphinx::Index.define :post, :with => :active_record do indexes :title, as: :post_title indexes :desc, as: :description indexes tags(:name), as: :tag_name #indexes happening_on, sortable: true #has author_id, published_at has published_at has last_touched has state has published set_property:field_weights => { :post_title => 5, :description => 1, :tag_name => 10 } end 
+1
source share
1 answer

Sphinx's String attributes can only be used for sorting, not filtering, not grouping, and so your options for working around this are:

  • Push it into a related model (State or PostState, maybe?), And then replace it with the type of foreign key.
  • Save this value as a field instead and use: conditions instead: s.
  • Hack it with CRC32 values .

I highly recommend the first of these options (I would say that it is cleaner, more precisely), but it depends on you.

+3
source

Source: https://habr.com/ru/post/1494174/


All Articles