当前位置: 代码迷 >> 综合 >> elasticsearch 笔记十一:搜索请求和timeout
  详细解决方案

elasticsearch 笔记十一:搜索请求和timeout

热度:99   发布时间:2023-12-16 17:14:11.0
{"took": 10,   //花费多少ms"timed_out": false,"_shards": {"total": 9,   //到多少shard"successful": 9,"failed": 0},"hits": {"total": 7,"max_score": 1,"hits": [{"_index": ".kibana","_type": "config","_id": "5.2.0","_score": 1,"_source": {"buildNum": 14695}},{"_index": "test_index","_type": "test_type","_id": "7","_score": 1,"_source": {"test_field": "test test"}},{"_index": "ecommerce","_type": "product","_id": "2","_score": 1,"_source": {"name": "jiajieshi yagao","desc": "youxiao fangzhu","price": 25,"producer": "jiajieshi producer","tags": ["fangzhu"]}},{"_index": "ecommerce","_type": "product","_id": "4","_score": 1,"_source": {"name": "heiren","desc": "xiren yagao","price": 50,"producer": "jiajieshi yagao","tags": ["heiren"]}},{"_index": "test_index","_type": "test_type","_id": "10","_score": 1,"_source": {"test_field": "test test","test_field1": "test test"}},{"_index": "ecommerce","_type": "product","_id": "1","_score": 1,"_source": {"name": "heiren","desc": "xiren yagao","price": 50,"producer": "jiajieshi yagao","tags": ["heiren"]}},{"_index": "ecommerce","_type": "product","_id": "3","_score": 1,"_source": {"name": "zhonghua yagao","desc": "caoben zhiwu","price": 40,"producer": "zhonghua producer","tags": ["qingxin"]}}]}
}

hits.total 本次搜索返回几条结果

hits.max_score:本次搜索的所有的结果中,最大的相关度分数是多少

hits.hits:默认查询前10条数据,完整数据,_score降序

timeout机制

timeout 机制,指定每个shard,就只能在timeout时间范围内将搜索到的数据返回。而不是等到全部数据全部检索出来才返回。

GET /_search?timeout=1ms

 

 

 

 

 

  相关解决方案