3

将 Elastic Search NEST 从 7.0.0-alpha2 升级到 7.0.1 后,我不再能够在 Nest.ElasticClient 中使用 IndexExistsAsync 方法。

根据文档,该方法已被删除并且是一项重大更改,因此我将调用更改为 ElasticClient.Indices.ExistsAsync 如下:

旧代码:

var existsResponse = await _elasticClient.IndexExistsAsync(model.Name);

新代码:

var existsResponse = await _elasticClient.Indices.ExistsAsync(model.Name);

使用新代码,我得到以下响应,这对于查找和解决问题并没有真正的帮助:

Invalid NEST response built from a successful (404) low level call on HEAD: /12-e449636ee7e1eb1343414698c95ce1e1

Audit trail of this API call:
- [1] HealthyResponse: Node: http://localhost:9200/ Took: 00:00:00.1208228

Request:

Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.

Response:

Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.

设置connectionSettings.DisableDirectStreaming(true);没有帮助,我得到了完全相同的响应。

非常感谢任何帮助。

4

2 回答 2

1

我认为你看到的信息告诉了你一切。

Invalid NEST response built from a successful (404) low level call on HEAD: /12-e449636ee7e1eb1343414698c95ce1e1 

response built from a successful- elasticsearch 调用成功,但返回状态 404(不存在)并映射到在existsResponse.Exists这种false情况下。没有附加额外的请求/响应信息,这就是您看到的原因:

Request:

Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.

Response:

Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.

当您尝试通过 kibana 执行此操作时,行为相同:

在此处输入图像描述

在此处输入图像描述

更新:

使用 elasticsearch 7.2.0 和 NEST 7.0.1 测试以下代码时

var client = new ElasticClient(connectionSettings);              

await client.Indices.CreateAsync("documents");                   
var exists = await client.Indices.ExistsAsync("documents");      
Console.WriteLine($"Index created, exists?: {exists.Exists}");   

await client.Indices.DeleteAsync("documents");                   
exists = await client.Indices.ExistsAsync("documents");          
Console.WriteLine($"Index deleted, exists?: {exists.Exists}");   

印刷

Index created, exists?: True
Index deleted, exists?: False

希望有帮助。

于 2019-07-07T09:02:29.270 回答
0

这里同样的问题。在针对版本为 7.2.0 的 ElasticSearch 集群升级到 Nest 7(7.0.0 和 7.0.1)后,我们收到以下消息:

从 HEAD 上的不成功 (502) 低级别调用构建的无效 NEST 响应:/leads_2019.07

此 API 调用的审计跟踪:

  • [1] 错误响应:节点:http://xxx:9200/接受:00:00:00.1931249

    OriginalException:Elasticsearch.Net.ElasticsearchClientException:请求执行失败。呼叫:状态码 502 来自:HEAD /leads_2019.07

对于版本为 6.8.1 的集群,我们会遇到相同的错误

于 2019-07-10T10:51:48.173 回答