【发布时间】:2012-07-18 13:15:50
【问题描述】:
我的 Rails 应用程序中的 Thinking Sphinx 存在严重问题。我的应用规格如下:
- Rails 3.2.6
- Ruby 1.9.3
- 狮身人面像 2.0.4 (r3135)
- 思考狮身人面像 2.0.12
在我的应用程序中,我有一个 Page 模型和一个 Offer 模型,pages 有很多 offers。 Page 模型中定义的索引如下所示:
define_index do
#other indexes defined here
#...
has offers.width, as: :offers_width
has offers.height, as: :offers_height
has offers.price, as: :offers_price
set_property delta: true
end
然后我在 Page 模型上进行搜索,其中 pages 是根据搜索查询和条件选择的。但是,当我尝试使用:with 过滤器时,Sphinx 给了我错误的结果。
当我只使用一个过滤器时,例如price 或width,结果还可以,但是当我尝试组合过滤器时,例如price and width,我得到的结果包含给定的报价price 或 width,而不是 price 和 width。
当我使用范围搜索时,大多数时候:with 参数是范围,而不仅仅是整数值。
编辑 1
使用以下方式查询即时消息:
Page.search Riddle.escape(query), conditions: conditions, with: has_cond, star: true, per_page: Page.per_page, page: page
has_cond 是:
{:offers_height=>[175..200], :offers_width=>[175..200], :offers_price=>[10..80]}
它仍然会为我提供 ANY 报价的高度在该范围内或 ANY 报价的宽度在该范围内的页面该范围或与价格相同的东西。
【问题讨论】:
-
你能发布搜索电话吗?
-
当然,我已经编辑了我的帖子。
标签: ruby-on-rails ruby activerecord thinking-sphinx