gpt4 book ai didi

ruby-on-rails - 手动重新安装(没有自制程序)时,RSPEC找不到 Elasticsearch

转载 作者:行者123 更新时间:2023-12-03 00:42:12 25 4
gpt4 key购买 nike

我已经研究了这个问题几周了。我正在使用的Rails应用程序使用Elasticsearch 1.5。我当时使用自制软件管理Elasticsearch,并将Elasticsearch升级到2.x。该应用程序无法在此最新版本的Elasticsearch中运行,并且搜索功能完全停止工作(由于不赞成使用facet)。虽然计划在接下来的几个月中迁移到聚合,但是我还有其他问题需要解决,所以我 brew 了卸载新版本的Elasticsearch的工作。我们的应用程序的版本无法通过自制软件获得,因此我在线上找到了它,并使用zip下载并安装了它。搜索功能可以再次与该应用一起使用,但是现在rspec找不到 flex 搜索,也将完全无法运行。它说Elasticsearch正在启动,但随后引发错误:

Starting 1 Elasticsearch nodes...sh: elasticsearch: command not found. 

&然后出现此错误:
/.rvm/gems/ruby-2.0.0-p643/gems/elasticsearch-extensions-0.0.18
/lib/elasticsearch/extensions/test
/cluster.rb:240:in `sleep': execution expired (Timeout::Error)

为了开始进行从方面到聚合的迁移,我必须使rspec正常工作。在此先感谢您的帮助。我已经为我的elasticsearch位置设置了bash别名。我的猜测是rspec找不到手动安装的版本,但是我不清楚在哪里处理。
spec_helper code:

def start_es_server
Elasticsearch::Extensions::Test::Cluster.start(nodes: 1) unless Elasticsearch::Extensions::Test::Cluster.running?

# create index(s) to test against.
create_es_index(Item)
end

def stop_es_server
Elasticsearch::Extensions::Test::Cluster.stop if Elasticsearch::Extensions::Test::Cluster.running?
end

RSpec.configure do |config|
config.include Capybara::DSL
config.mock_with :rspec
config.use_transactional_fixtures = true
config.infer_spec_type_from_file_location!

config.raise_errors_for_deprecations!

config.expect_with(:rspec) { |c| c.syntax = [:should, :expect] }
config.mock_with :rspec do |mocks|
mocks.syntax = [:should, :expect]
mocks.verify_partial_doubles = true
end

最佳答案

我通过查看https://github.com/elastic/elasticsearch-ruby/blob/b3cfdcbde678c2704c0a557a163782b9e027d144/elasticsearch-extensions/lib/elasticsearch/extensions/test/cluster.rb找到了这个问题的答案。可以传递给start方法的可选参数列表包括一个称为:command的参数,默认为'elasticsearch'。可以使用指向您的elasticsearch位置的直接路径来覆盖它:

elasticsearch = '/usr/local/elasticsearch-1.5.2/bin/elasticsearch'
Elasticsearch::Extensions::Test::Cluster.start(nodes: 1, command: elasticsearch) unless Elasticsearch::Extensions::Test::Cluster.running?

关于ruby-on-rails - 手动重新安装(没有自制程序)时,RSPEC找不到 Elasticsearch ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34688209/

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