直到ElasticSearch 6.0,我们才能够将搜索请求(SearchRequest的对象)序列化为字符串
using (System.IO.MemoryStream mStream = new System.IO.MemoryStream())
{
ElasticClient.Serializer.Serialize(searchRequest, mStream);
string rawQueryText = Encoding.ASCII.GetString(mStream.ToArray());
}
示例也在这里serialize query from Nest client elastic search 2.3
但是在已删除的6.4版本中,我无法准确找到将6.4版本的查询序列化的文档的位置 https://github.com/elastic/elasticsearch-net
有人可以帮我吗?
答案 0 :(得分:0)
您可以在Elasticsearch.Net的ElasticsearchSerializerExtensions中使用扩展方法
using Elasticsearch.Net;
using Nest;
var client = new ElasticClient();
var searchRequest = new SearchRequest
{
Query = new MatchAllQuery()
};
var json = client.RequestResponseSerializer.SerializeToString(searchRequest);