我不想对一组类进行全局搜索,但我想指定它应该使用的索引数组,这可能吗?我已经用谷歌搜索并尝试了不同的解决方案,但还没有运气。
这可以正常工作(尽管对于一个索引)。
ThinkingSphinx.search "query", :classes => [Foo, Bar], :index => "my_foo_index"
这会引发错误:
ThinkingSphinx.search "query", :classes => [Foo, Bar], :index => "my_foo_index,my_bar_index"
> ThinkingSphinx::SphinxError: distributed index 'my_foo_index' in multi-index query found
这样做:
ThinkingSphinx.search "query", :classes => [Foo, Bar], :index => ["my_foo_index", "my_bar_index"]
> NoMethodError: undefined method `force_encoding' for ["my_foo_index", "my_bar_index"]:Array
我还尝试将模型索引命名为相同的名称,例如 Foo 模型和 Bar 模型上的“my_index”,但是在重建索引时出现此错误:
ERROR: section 'my_index_core_0' (type='source') already exists in /dev/config/development.sphinx.conf line 116 col 1.
我能想出的唯一解决方案是对每个模型进行多次搜索,然后合并结果。不过这有点吹,因为我会在搜索中失去相关性......
有任何想法吗?