升级到Elastic Search NEST 7.0.1会破坏检查索引是否存在的代码

时间:2019-07-06 20:16:26

标签: elasticsearch indexing nest nuget-update

将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);并没有帮助,我得到的响应完全相同。

我们非常感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

我认为您看到的消息可以告诉您所有内容。

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

response built from a successful-弹性搜索调用成功,但是状态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进行操作时具有相同的行为:

enter image description here

enter image description here

更新:

在用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

希望有帮助。

答案 1 :(得分:0)

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

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

此API调用的审核记录:

  • [1] BadResponse:节点:http://xxx:9200/进行了:00:00:00.1931249

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

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