ruby-on-rails - Elasticsearch 在 localhost 中运行良好,但在测试时出现连接错误
问题描述
我是 Elasticsearch 和 Docker 的新手。我正在使用我的应用程序获取搜索结果,但是当我对相同的应用程序运行测试时,我遇到了这样的连接错误
cannot assign requested address - cannot assign requested address - connect(2) for "localhost" port 9200 (localhost:9200)
我正在使用chewy gem
ofruby on rails
来实现Elasticsearch
这是搜索的示例代码
result = TestIndex::Test
.filter(match: { test_id: testid })
.query(something
})
.highlight({something
}
})
.paginate(page: page, per_page: page_size).as_json
我正在测试使用Rspec
注意搜索在应用程序中运行良好。运行测试文件时出现此错误
解决方案
推荐阅读
- reporting-services - 如何在 SSRS 中添加回车/换行
- c++ - 如何编译 CUDA C++ 项目
- wordpress - 向 Wordpress 插件的类函数添加过滤器
- c# - 带有两个 select 和 where 条件的 Linq 语句
- python - 用于通信 python - C++ 的 UNIX 套接字
- ios - pod FBSDKCoreKit 的 react-native-fbsdk 问题
- angular - Angular:从列表中链接两个不同的复选框
- graphql - Graphql 突变与 aws-appsync 上的父对象和子数组
- r - 如何使用“包含”和“ifelse”有条件地改变多个列?
- python - Discord.py - 获取随机 imgur 图像