boe*_*ena 2 ruby sphinx ruby-on-rails thinking-sphinx ruby-on-rails-3
我不想对一组类进行全局搜索,但是我想指定它应该使用的索引数组,这可能吗?我用谷歌搜索并尝试了不同的解决方案,但没有运气.
这工作正常(虽然一个索引).
ThinkingSphinx.search "query", :classes => [Foo, Bar], :index => "my_foo_index"
Run Code Online (Sandbox Code Playgroud)
这会引发错误:
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
Run Code Online (Sandbox Code Playgroud)
就像这样:
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
Run Code Online (Sandbox Code Playgroud)
我还尝试将模型索引命名为相同,如Foo模型和Bar模型上的"my_index",但是在重建索引时我遇到了这个错误:
ERROR: section 'my_index_core_0' (type='source') already exists in /dev/config/development.sphinx.conf line 116 col 1.
Run Code Online (Sandbox Code Playgroud)
我能想到的唯一解决方案是对每个模型进行多次搜索,然后合并结果.虽然我会在搜索中失去相关性,但这有点震撼......
有任何想法吗?
请尝试以下方法:
ThinkingSphinx.search 'query', :classes => [Foo, Bar],
:index => 'my_foo_index_core,my_bar_index_core'
Run Code Online (Sandbox Code Playgroud)
如果你有增量,增加my_foo_index_delta和my_bar_index_delta向名单.这将避免分布式指数.
| 归档时间: |
|
| 查看次数: |
1874 次 |
| 最近记录: |