您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
elasticSearch的URI搜索-size及其与terminate_after的区别
发布时间:2021-09-02 19:04:07编辑:雪饮阅读()
在elasticSearch中URI搜索中size参数和terminate_after参数有点相似。
一个请求:
请求体:none
响应体:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 4,
"relation": "eq"
},
"max_score": 1.0,
"hits": [
{
"_index": "schools",
"_type": "school",
"_id": "1",
"_score": 1.0,
"_source": {
"name": "Central School4",
"description": "CBSE Affiliation",
"street": "Nagan",
"city": "paprola",
"state": "HP",
"zip": "176115",
"location": [
31.8955385,
76.8380405
],
"fees": 2004,
"tags": [
"Senior Secondary",
"beautiful campus"
],
"rating": "3.5"
}
}
]
}
}
这里size主要是指定了响应回来的数据条目为1,但是我们可以看到响应结果中的确是只给响应了一条数据,但实际上命中的是4条数据。
那么也就是说,这个size主要控制响应回来的数据的,那么如果我们只需要知道一个查询是否能够匹配到数据,则我们可以直接size=0,这样节约了性能,然后同时追加terminate_after=1(只要有文档就立即返回)。
关键字词:elasticSearch,URI,size,terminate_after