gpt4 book ai didi

ruby-on-rails - Thinking Sphinx——在配置文件中找不到索引

转载 作者:行者123 更新时间:2023-12-04 06:16:17 26 4
gpt4 key购买 nike

尝试使用 Thinking Sphinx 进行搜索。已关注 this Railscast通过自制安装 TS 和 MySQL(虽然我在我的应用程序中使用 pg,它显然是必需的),将这些行添加到我的 gemfile 中:

gem 'mysql2'
gem 'thinking-sphinx'

并将以下内容放入我的模型中,低于其他所有内容

post.rb
class Post < ActiveRecord::Base
#...

define_index do
indexes content
indexes :name
end
end

然后我进入终端并尝试 rake ts:index,但我收到此错误:
 using config file '/Users/<personal>/rails_projects/<personal>/config/development.sphinx.conf'...
FATAL: no indexes found in config file '/Users/<personal>/rails_projects/<personal>/config/development.sphinx.conf'

Fished around on the internet并没有发现什么可以完全回答这个问题。我试过运行 rake ts:configure(它不会提示)然后 rake ts:index,但它不起作用。

一些背景:我刚刚更改了我的终端 shell (使用 zsh),这进行了各种奇怪的意外更改。我不得不重新安装bundler,然后重新捆绑安装我所有的gem,然后独立gem install rake。然后我捆绑更新以进行良好的衡量。现在 rake 似乎可以工作了,但我仍然收到错误消息。

错误提示的配置文件:
indexer
{
}

searchd
{
listen = 127.0.0.1:9306:mysql41
log = /Users/<personal>/rails_projects/<personal>/log/development.searchd.log
query_log = /Users/<personal>/rails_projects/<personal>/log/development.searchd.query.log
pid_file = /Users/<personal>/rails_projects/<personal>/log/development.sphinx.pid
workers = threads
binlog_path = /Users/<personal>/rails_projects/<personal>/tmp/binlog/development
}

任何想法发生了什么/答案可能在什么代码中?

有趣的更新 -- 我关注了 this Google Group 上的问答进入我的 rails 控制台并输入“Post.sphinx_indexes.length”,但我得到了这个非常不同的错误作为返回。看起来我的模型以某种方式无法访问 gem?
NoMethodError: undefined method `define_index' for #<Class:0x007f9c06c611b0>
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activerecord-3.2.11/lib/active_record/dynamic_matchers.rb:55:in `method_missing'
from /Users/<personal>/rails_projects/<personal>/app/models/post.rb:55:in `<class:Post>'
from /Users/<personal>/rails_projects/<personal>/app/models/post.rb:13:in `<top (required)>'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:469:in `load'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:469:in `block in load_file'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:639:in `new_constants_in'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:468:in `load_file'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:353:in `require_or_load'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:502:in `load_missing_constant'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:192:in `block in const_missing'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:190:in `each'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:190:in `const_missing'
from (irb):1
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /Users/<personal>/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/gems/1.9.1/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'irb(main):002:0>

最佳答案

还将这个问题发布到 Thinking Sphinx Google Group 并在那里得到了答案,所以我将其粘贴在下面。在回答上述问题后,我遇到了另一个错误并在那里进行了跟进,所以如果有人想了解更多信息,this discussion应该希望继续有帮助。

我引用:

Hi Sasha The issue is that Thinking Sphinx's documentation is mostly for v2, but v3 is what you're using (and much better). Index definitions are now located in app/indices - the README is your best source of information (but anything it doesn't cover is probably the same as earlier versions): https://github.com/pat/thinking-sphinx/blob/master/README.textile

Have a read through of that, move your index definition, and you should be good to go. Any further issues, get in touch :)

-- Pat



在那个问题之后,我遇到了这个问题,这显然是因为 Sphinx 无法访问我的 PostgreSQL 数据库。
indexing index 'post_core'...
ERROR: source 'post_core_0': unknown type 'pgsql'; skipping.
ERROR: index 'post_core': failed to configure some of the sources, will not index.
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg

我通过卸载 Sphinx 和两个 gems(thinking_sphinx 和 mysql2)来解决这个问题,然后使用 mysql 和 pgsql 标志 brew 安装 Sphinx,然后重新安装 gems。

在那之后, rake ts:index 就像一个魅力。

关于ruby-on-rails - Thinking Sphinx——在配置文件中找不到索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15238022/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com