您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch响应过滤(filter_path)
发布时间:2021-08-27 11:48:49编辑:雪饮阅读()
像是请求
http://localhost:9200/<accountdetail-{now{YYYY.MM|+12:00}}>/_search?human=true get
请求体:
{
"profile": true
}
响应体:
{
"took": 74,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "accountdetail-2021.08",
"_type": "type1",
"_id": "6",
"_score": 1.0,
"_source": {
"AccountID": "2021.08",
"bbq": "上次货币质入金额",
"PreFundMortgageOut": "上次货币质出金额",
"PreMargin": "上次占用的保证金",
"PreMortgage": "上次质押金额"
}
}
]
},
"profile": {
"shards": [
{
"id": "[qyWfA-ewRZe_ZLeMwNimGw][accountdetail-2021.08][0]",
"searches": [
{
"query": [
{
"type": "MatchAllDocsQuery",
"description": "*:*",
"time": "19.9ms",
"time_in_nanos": 19987000,
"breakdown": {
"set_min_competitive_score_count": 0,
"match_count": 0,
"shallow_advance_count": 0,
"set_min_competitive_score": 0,
"next_doc": 1400,
"match": 0,
"next_doc_count": 1,
"score_count": 1,
"compute_max_score_count": 0,
"compute_max_score": 0,
"advance": 2000,
"advance_count": 1,
"score": 1400,
"build_scorer_count": 2,
"create_weight": 19432000,
"shallow_advance": 0,
"create_weight_count": 1,
"build_scorer": 550200
}
}
],
"rewrite_time": 10000,
"collector": [
{
"name": "SimpleTopScoreDocCollector",
"reason": "search_top_hits",
"time": "17.9micros",
"time_in_nanos": 17900
}
]
}
],
"aggregations": []
}
]
}
}
这是一个profile API性能分析接口的响应结果。这个响应体太庞大了,那么假如我只想看hits.total的json数据结构,其它的不想让它显示出来,响应体如:
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
那么其实也很容易做到,filter_path参数可以过滤响应体,像上面这个需求我们直接拼接filter_path=hits.total。
那么一个新的请求如:
请求体:
{
"profile": true
}
响应体:
{
"hits": {
"total": {
"value": 1,
"relation": "eq"
}
}
}
关键字词:filter_path,响应过滤,elasticSearch