Reputation: 2999
Getting this error with 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'
error is being thrown in the template at the line of a partial collection: @posts_by_state, but two other instances of the same partial are working great. The State sort is what is throwing it off.
@posts_by_state = Post.search(params[:search], with: { state: current_user.state, published: true }, :page => params[:page], :per_page => 10)
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
Upvotes: 1
Views: 5724
Reputation: 16226
String attributes in Sphinx can only be used for sorting - not filtering, not grouping - and so your options to work around this are as follows:
I highly recommend the first of these options (I'd argue it's cleaner, accurate), but it's up to you.
Upvotes: 3