从Nest客户端进行序列化查询弹性搜索2.3 [英] serialize query from Nest client elastic search 2.3
问题描述
由于将我的Nest客户端升级到2.2.1,我无法看到我提交给我的弹性搜索客户端(现在是2.3.0版本)的查询。
我曾经使用这一行:
Since upgrading my Nest client to 2.2.1 I'm unable see the query I'm submitting to my elastic search client (now version 2.3.0). I used to use this line:
string searchJson = Encoding.UTF8.GetString(client.Serializer.Serialize(myQueryHere));
但是,此方法现在返回void而不是以前使用的JSON。
ConnectionStatus也不存在,所以我不能再看到我发送的json,有人知道一个方法吗? CallDetails.RequestBodyInBytes可用,但返回null。
But this method now returns void instead of the JSON it used to. ConnectionStatus also doesn't exist so I can no longer see the json i'm sending, does anyone know of a way? CallDetails.RequestBodyInBytes is available but that returns null.
推荐答案
查看连接时NEST 2.x的文档。 CallDetails.RequestBodyInBytes
将 null
除非您设置 .DisableDirectStreaming()
传递给的构造函数ElasticClient
Take a look at the documentation for NEST 2.x on Connecting. CallDetails.RequestBodyInBytes
will be null
unless you set .DisableDirectStreaming()
on ConnectionSettings
that is passed to the constructor of ElasticClient
var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var settings = new ConnectionSettings(connectionPool)
.DisableDirectStreaming();
var client = new ElasticClient(settings);
现在,请求和响应字节的副本将在响应CallAttribute上显示
now a copy of the request and response bytes will be exposed on the response CallDetails
var response = client.Search<Document>();
var requestJson = Encoding.UTF8.GetString(response.CallDetails.RequestBodyInBytes);
var responseJson = Encoding.UTF8.GetString(response.CallDetails.ResponseBodyInBytes);
这篇关于从Nest客户端进行序列化查询弹性搜索2.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!