Elasticsearch:避免结果集中的 return "sort" 值

Elasticsearch: avoid to return "sort" value in the resultset

我有这个简单的搜索:

{
   "from": 0,
   "size": 5,
   "query": {
      "match_all": {}
   },
   "_source": [
     "info"
   ],
   "sort": {
      "date": {
         "order": "desc"
      }
   }
}

结果集是:

"hits":{
  "hits":[
    {"sort":[-9223372036854775808 ], "_type": "reports", "_source": …},
    {"sort":[-9223372036854775808 ], "_type": "reports", "_source": …},
    {"sort":[-9223372036854775808 ], "_type": "reports", "_source": …},
    {"sort":[-9223372036854775808 ], "_type": "reports", "_source": …},
    {"sort":[-9223372036854775808 ], "_type": "reports", "_source": …}
  ],
  "total": 38,
  "max_score": null
},
"_shards":{
  "successful": 15,
  "failed": 0,
  "total": 15
},
"took": 11,
"timed_out": false

是否可以从结果集中删除字段 "sort":[-9223372036854775808 ]?我必须用这个结果创建一个 json,但我得到了一个错误 (json_decode(): integer overflow detected),因为这个字段中有这个大整数。

您绝对不能 return 在查询中使用 response filtering sort

在查询的 URL 中,只需添加以下查询字符串参数:

...&filter_path=hits.hits._source,hits.hits._id,hits.hits._type,hits.hits._index

您将在每个匹配中获得所有 JSON 字段,sort 字段除外。