【发布时间】:2017-12-12 12:21:10
【问题描述】:
我想为同一个模型创建两个索引并分别搜索
我正在使用
gem 'thinking-sphinx', '3.2.0'
gem 'riddle', '1.5.11'
ThinkingSphinx::Index.define :product, :with => :active_record, :delta => ThinkingSphinx::Deltas::DelayedDelta do
indexes :field_a
end
ThinkingSphinx::Index.define :product, :name => "active_product", :with => :active_record, :delta => ThinkingSphinx::Deltas::DelayedDelta do
indexes :field_a
where "(active = 1)"
end
当我尝试以这种方式搜索以仅获取有效产品时
Product.search_for_ids "", :match_mode => :extended, :index => "active_product_core, active_product_delta", :page => params[:page], :per_page => 50, :sort_mode => :extended, :order => "field_a desc"
但它正在运行这样的查询并列出所有产品
SELECT * FROM `product_core`, `product_delta` WHERE `sphinx_deleted` = 0 ORDER BY `field_a` desc LIMIT 0, 50 OPTION max_matches=50000
我怎样才能只获得有效产品或确保查询像这样运行?
SELECT * FROM `active_product_core`, `active_product_delta` WHERE `sphinx_deleted` = 0 ORDER BY `field_a` desc LIMIT 0, 50 OPTION max_matches=50000
注意:上述功能在 Thinking sphinx 版本 2 中运行良好
gem 'thinking-sphinx', '2.0.14'
gem 'riddle', '1.5.3'
【问题讨论】:
标签: thinking-sphinx