我是 ElasticSearch 的新手,我在 C# 中设置了一个 AWS Lambda 函数来获取 S3 对象(包含 JSON 数据)的内容,希望将它们发布到 ES 以供搜索。
我正在使用 Elasticsearch.Net nuget 库。
在此处的文档中 - https://github.com/elastic/elasticsearch-net有配置节点 URI 等的示例,但我的理解是,对 ES 的任何请求都需要使用 AWS Signature V4(基于访问/ secret key )进行签名。为此,我创建了一个 IAM 用户,但在文档中找不到任何地方可以找到如何签署 POST 请求。示例显示了发布方法,但没有包含签名的地方?
例如
var person = new Person
{
FirstName = "Martijn",
LastName = "Laarman"
};
var indexResponse = lowlevelClient.Index<BytesResponse>("people", "person", "1", PostData.Serializable(person));
byte[] responseBytes = indexResponse.Body;
var asyncIndexResponse = await lowlevelClient.IndexAsync<StringResponse>("people", "person", "1", PostData.Serializable(person));
string responseString = asyncIndexResponse.Body;
即使在实例化连接时,也没有地方可以添加您的凭据?
var settings = new ConnectionConfiguration(new Uri("http://example.com:9200"))
.RequestTimeout(TimeSpan.FromMinutes(2));
var lowlevelClient = new ElasticLowLevelClient(settings);
我已经检查了 ConnectionConfiguration 对象,但没有似乎相关的方法或属性。我错过了什么?
最佳答案
使用 elasticsearch-net-aws包你应该能够像这样设置低级客户端:
var httpConnection = new AwsHttpConnection("us-east-1"); // or whatever region you're using
var pool = new SingleNodeConnectionPool(new Uri(TestConfig.Endpoint));
var config = new ConnectionConfiguration(pool, httpConnection);
config.DisableDirectStreaming();
var client = new ElasticLowLevelClient(config);
// ...
关于c# - ElasticSearch.NET 在 POST 请求中传递 AWS Signature v4?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53491125/