Rails 的 Thinking Sphinx 插件的关联问题
我的应用程序模型中有许多 sphinx_scope,但其中之一 它们不起作用,我认为这是因为 Sphinx 存储的奇怪方式 相关值。
作为一个例子,我将展示我的产品类模型的一些关键部分, Product.rb:
...
belongs_to :partner
# And partner belongs to city
...
define_index do
...
has partner.city(:state_name), :as => :state, :type => :string
#has partner.city.state_name, :as => :state, :type => :string
...
end
...
sphinx_scope(:by_state) { | name | {
:with => { :state => name }
} }
然后我在控制台中尝试:
Product.by_state('whatever_i_put_here_throws_same_resultset')
我猜 sphinx 没有正确存储字符串,有什么想法吗?谢谢一个 很多!
I have many sphinx_scopes in my application's models, but one of
them doesn't work, I think it's because the odd way Sphinx store the
associated values.
As an example I will show some key pieces of my Product class model,
product.rb:
...
belongs_to :partner
# And partner belongs to city
...
define_index do
...
has partner.city(:state_name), :as => :state, :type => :string
#has partner.city.state_name, :as => :state, :type => :string
...
end
...
sphinx_scope(:by_state) { | name | {
:with => { :state => name }
} }
Then I try in console:
Product.by_state('whatever_i_put_here_throws_same_resultset')
I guess sphinx is not storing the string properly, any ideas? Thanks a
lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
询问作者:http://groups.google.com/group/ Thinking-sphinx/browse_thread/thread/22fe3c7aa6ef4567
在这里发现问题:http://freelancing-god.github.com/ts/en/common_issues.html#string_filters
Asked the authors: http://groups.google.com/group/thinking-sphinx/browse_thread/thread/22fe3c7aa6ef4567
Found the problem here: http://freelancing-god.github.com/ts/en/common_issues.html#string_filters
您将范围定义为
:by_state
,但您尝试调用Product.by_city
。是否还定义了我们在这里没有看到的另一个范围?You defined your scope as
:by_state
but you're trying to callProduct.by_city
. Is there another scope defined that we're not seeing here?