抱歉重复的问题,但这似乎不与当前的弹性搜索2工作。x版本。基本上,我使用NEST向ES发送查询,并希望获得纯JSON形式的响应,就像在Sense上使用POST命令一样。这里存在类似的问题:在ElasticSearch NEST查询中返回原始Json
使用
检索的结果var searchResult = _elasticClient.LowLevel.Search<SearchResponse<SearchResult>>(querytEST);
结果希望:
{
"took": 406,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 14,
"max_score": 0,
"hits": []
},
"aggregations": {
"query": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 1,
"buckets": [
{
"key": "laura",
"doc_count": 14,
"top": {
"hits": {
"total": 14,
"max_score": 4.1078563,
"hits": [
{...
在底层客户端传递给.Search<T>
的类型T
指定了返回结果的类型。为了得到json返回,您只需要将其更改为string
var searchResult = _elasticClient.LowLevel.Search<string>(querytEST);