I wan't to make a global search on a set of classes but I would like to specify an array of indexes it should use, is this possible? I have googled and tried different solutions but no luck yet.
This works correctly (for one index though).
ThinkingSphinx.search "query", :classes => [Foo, Bar], :index => "my_foo_index"
This throws an error:
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
As do this:
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
I also tried to name the models index the same, like "my_index" on both the Foo-model and the Bar-model but then I got this error when rebuilding the index:
ERROR: section 'my_index_core_0' (type='source') already exists in /dev/config/development.sphinx.conf line 116 col 1.
The only solution I can come up with is to do multiple searches for each model and then merge the results. That blows a little though since I will loose relevance in the search...
Any ideas?
Try the following:
ThinkingSphinx.search 'query', :classes => [Foo, Bar],
:index => 'my_foo_index_core,my_bar_index_core'
If you have deltas, add my_foo_index_delta
and my_bar_index_delta
to the list as well. That'll avoid the distributed indices.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.