Cu1*_*ure 8 ruby indexing ruby-on-rails elasticsearch
我很高兴在Rails应用程序中使用Elasticsearch并使用耐嚼的gem来实现它.当我通过rails sI 在开发模式下运行rails应用程序时,然后通过elasticsearch命令运行Elasticsearch 并运行rake chewy:reset:all以创建我的数据的索引.
一切正常,但是如果我重新启动服务器,我必须rake chewy:reset:all再次运行命令来重建索引,否则我会收到错误.重启服务器时索引会发生什么?它在服务器停止时被销毁了吗?
我对Elasticsearch的功能并不是很熟悉,所以我很欣赏任何人对幕后发生的事情有所了解.
我从未使用过 Chewy,但根据他们的文档判断,如果您将“Chewy.settings = {prefix: 'test'}”放入 config/initializers/chewy.rb 中,它将在所有内容前面加上 'test' 前缀,这也在开发中。当然,我不知道你是否把它放在那里。
另请注意,cucumber 倾向于在开发模式下运行测试(https://github.com/cucumber/cucumber-rails/issues/222)。
因此,尝试从代码中删除“Chewy.settings = {prefix: 'test'}”,并将类似的内容放入 Chewy.yml 文件中:
# config/chewy.yml
cucumber:
host: 'localhost:9200'
prefix: 'test'
Run Code Online (Sandbox Code Playgroud)
然后将其添加到您的黄瓜 env.rb 文件中:
ENV["RAILS_ENV"] ||= 'cucumber'
Run Code Online (Sandbox Code Playgroud)
并尝试使用 rake cucumber 再次运行 cucumber
| 归档时间: |
|
| 查看次数: |
737 次 |
| 最近记录: |