【问题标题】:Connecting to AWS Elasticsearch Service using R - Getting 404 Error使用 R 连接到 AWS Elasticsearch Service - 出现 404 错误
【发布时间】:2016-12-01 06:40:57
【问题描述】:

我正在尝试通过 R 中名为 elastic 的包查询 AWS ElasticSearch Service (AWS ES)。尝试连接到服务器时出现错误。

这是一个例子:

install.packages("elastic")
library(elastic)
aws_endpoint = "<secret>"
   # I am certain the endpoint exists and is correct, as it functions with Kibana
aws_port = 80    
   # I have tried 9200, 9300, and 443 with no success

connect(es_host = aws_endpoint, 
    es_port = 80,
    errors = "complete")
ping()
Search(index = "foobar", size = 1)$hits$hits

无论是 ping 服务器,还是实际尝试搜索文档,都会检索到此错误:

Error: 404 - no such index
ES stack trace:
  type: index_not_found_exception
  reason: no such index
  resource.type: index_or_alias
  resource.id: us-east-1.es.amazonaws.com
  index: us-east-1.es.amazonaws.com

我已进入我的 AWS ES 控制面板并确定我正在使用现有的索引。为什么会出现这个错误?

我想我对传输协议有误解。 elastic 与 elasticsearch 的 HTTP API 交互。我以为这很好。

如何在 R 和 AWS ES 之间建立适当的连接?

R version 3.3.0 (2016-05-03); elastic_0.7.8

【问题讨论】:

  • AWS 的托管 Elasticsearch 版本要求对所有请求进行签名(参考 docs.aws.amazon.com/general/latest/gr/sigv4_signing.html)。我没有看到任何关于ropensci/elastic 包支持这个签名方案的明显参考。目前我不知道有任何 CRAN 软件包可以做到这一点。
  • 感谢@DavidF.Severski。我会调查一下。
  • 实际上,我们的服务器管理员说我们还没有保护 ES url,所以不需要签名。还有其他想法吗? @DavidF.Severski

标签: r amazon-web-services elasticsearch


【解决方案1】:

解决了。

es_path 必须指定为空字符串 ("")。否则,connect() 将 AWS 区域(即us-east-1.es.amazonaws.com)理解为路径。我想connect() 在 HTTP 请求中添加了被误解的路径,following the format shown here

connect(es_host = aws_endpoint, 
   es_port = 80,
   errors = "complete",
   es_path = "" 
)

为了清楚起见,我实际使用的参数如下所示,但它们应该没有区别。 修复es_path是关键

connect(es_host = aws_endpoint, 
    es_port = 443, 
    es_path = "", 
    es_transport_schema  = "https")

【讨论】:

  • 您能否举例说明 aws_endpoint 的外观?我正在努力寻找自己。提前致谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-21
相关资源
最近更新 更多