使用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'
错误在部分集合的行中被抛出:@posts_by_state,但是同一部分的另外两个实例工作得很好。国家排序就是把它抛弃了。
@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
答案 0 :(得分:3)
Sphinx中的字符串属性只能用于排序 - 不能过滤,不能用于分组 - 因此您可以选择解决此问题的方法如下:
我强烈推荐第一个选项(我认为它更清晰,准确),但这取决于你。