问题描述
我一直在使用 gem和elasticsearch,在Rails 4.2.0应用程序上没有问题。我有一个使用searchkick的视频模型。
I've been using the searchkick gem with elasticsearch with no problems on a Rails 4.2.0 application. I have a single Video model using searchkick.
由于某些原因 rake searchkick:reindex:all
现在始终失败
For some reason rake searchkick:reindex:all
is now failing consistently with:
我最初是通过 brew install elasticsearch安装了Elasticsearch
,它返回:
I originally installed elasticsearch via brew install elasticsearch
, which returns:
弹性搜索安装/数据库是否已损坏?如果是这样,刷新它的最佳方法是什么?
Is it likely that my elasticsearch installation/database has become corrupted? If so, what is the best way to refresh it?
根据 I尝试 curl -XDELETE'http:// localhost:9200 / _all'
,但这不能解决错误。
As per https://www.elastic.co/guide/en/elasticsearch/reference/1.4/indices-delete-index.html I tried curl -XDELETE 'http://localhost:9200/_all'
but this doesn't resolve the error.
当我将此代码部署到AWS时(以前都正常工作),在我的Mac上以及Elastic Beanstalk上都会发生此问题。
This problem occurs on my Mac, as well as Elastic Beanstalk when I deploy this code to AWS (both were previously working correctly).
推荐答案
通常经过数小时的奋斗,我在发布问题后几分钟找到了答案...
Typically after hours of struggling I found the answer minutes after posting the question...
根据我添加了带有以下内容的初始化程序:
As per https://github.com/ankane/searchkick/issues/382 I added an initializer with:
Searchkick.client = Elasticsearch::Client.new(hosts: ["localhost:9200"], retry_on_failure: true, transport_options: {request: {timeout: 250}})
这似乎已经解决了问题。我会再报告一次。
which seems to have solved the problem. I'll report back if it recurs.
这篇关于带有ElasticSearch的Searchkick返回“ Faraday :: ConnectionFailed:执行到期”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!