配置thinking-sphinx时出现问题,ThinkingSphinx::NoIndicesError

问题描述 投票:0回答:1

我正在运行一个带有

searchd
的 ubuntu 服务器,该服务器在创建索引后运行。

所以基本上所有的工作:

indexing index 'pois'...
WARNING: attribute 'id' not found - IGNORING
collected 1760907 docs, 27.4 MB
sorted 3.4 Mhits, 100.0% done
total 1760907 docs, 27438485 bytes
total 2.795 sec, 9813909 bytes/sec, 629822.77 docs/sec
total 1761030 reads, 0.347 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 334 writes, 0.072 sec, 621.5 kb/call avg, 0.2 msec/call avg
ubuntu@stl-back-3:/etc/sphinxsearch$ sudo searchd
Sphinx 2.2.11-id64-release (95ae9a6)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinxsearch/sphinx.conf'...
listening on 127.0.0.1:9312
listening on 127.0.0.1:9306
listening on xxx.xxx.xxx.xxx:9396
precaching index 'pois'
precached 1 indexes in 0.037 sec                            

然后我尝试配置 Rails 以使用这个

pois
索引

所以我这样设置我的配置:

  enable_star: true
  min_infix_len: 2
  max_matches: 10000
  version: '2.2.11'

  address: xxx.xxx.xxx.xxx
  port: 9396

是的,我用 telnet 仔细检查了,端口在 xxx.xxx.xxx.xxx:9396 上打开

然后我有一个像这样的简单模型:

  include ThinkingSphinx::ActiveRecord

  define_index "pois", with: :active_record do
    indexes name
    has latitude, longitude, population, altitude
  end
end

我也尝试过这种语法:

sphinx_scope(:source => :pois)

但是每当我尝试进行搜索时,都会发送以下错误:

Traceback (most recent call last):
ThinkingSphinx::NoIndicesError (ThinkingSphinx::NoIndicesError)

我想念什么?

非常感谢

ruby-on-rails thinking-sphinx
1个回答
0
投票

如果您想使用 Thinking Sphinx 将 Sphinx 与 Rails 集成,那么您需要使用 Thinking Sphinx 的 rake 任务,而不是直接调用

searchd
(以及
indexer
和其他 Sphinx CLI 可执行文件),例如
bundle exec rake ts:index
bundle exec rake ts:rebuild
https://freelancing-gods.com/thinking-sphinx/v5/rake_tasks.html

但是,正如 @smathy 在评论中指出的那样:模型中的

define_index
调用是一种 very 旧语法,自 Thinking Sphinx v2 (2013) 以来就不再使用,而自 v3 以来,索引定义位于它们自己的文件中在应用程序/索引中: https://freelancing-gods.com/thinking-sphinx/v5/indexing

认为 Sphinx v2 适用于 Rails 3.0/3.1 - 如果您使用的是较新版本的 Rails,那么您必须使用 TS v3 或更高版本(最好是 v5.5,它支持 Rails 4.2 及以上版本)。

© www.soinside.com 2019 - 2024. All rights reserved.