sphinxql:语法错误,意外 IDENT [英] sphinxql: syntax error, unexpected IDENT
本文介绍了sphinxql:语法错误,意外 IDENT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 sphinx 2 时出现此错误
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'
index.html.erb
在部分集合的行处的模板中抛出错误:@posts_by_state,但同一部分的另外两个实例运行良好.状态排序是什么把它扔掉.
index.html.erb
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)
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
推荐答案
Sphinx 中的字符串属性只能用于排序 - 不能过滤,不能分组 - 因此您可以解决此问题的选项如下:
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:
- 将其拉出到关联模型中(可能是 State 或 PostState?),然后改为按外键整数进行过滤.
- 将该值存储为一个字段,并使用 :conditions 而不是 :with.
- 使用CRC32 值解决这个问题.
- Pull it out into an associated model (State or PostState, perhaps?), and then filter by the foreign key integer instead.
- Store that value as a field instead, and use :conditions instead of :with.
- Hack around it with CRC32 values.
我强烈推荐这些选项中的第一个(我认为它更简洁、准确),但这取决于您.
I highly recommend the first of these options (I'd argue it's cleaner, accurate), but it's up to you.
这篇关于sphinxql:语法错误,意外 IDENT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文