1、_search 的返回结果代表什么

  1. {
  2. "took" : 0, #返回时间
  3. "timed_out" : false,
  4. "_shards" : {
  5. "total" : 1,
  6. "successful" : 1,
  7. "skipped" : 0,
  8. "failed" : 0
  9. },
  10. "hits" : {
  11. "total" : {
  12. "value" : 7, #本次搜索返回了多少结果
  13. "relation" : "eq"
  14. },
  15. "max_score" : 1.0,#本次搜索,最大的相关度分数是什么。相关度越高,分数越大,排位越靠前
  16. "hits" : [
  17. {
  18. "_index" : "bobotest",
  19. "_type" : "_doc",
  20. "_id" : "1",
  21. "_score" : 1.0,
  22. "_source" : {
  23. "name" : "tian bo",
  24. "desc" : "ke ai",
  25. "age" : 11,
  26. "tags" : [
  27. "keai",
  28. "kuaile"
  29. ]
  30. }
  31. }
  32. ]
  33. }
  34. }

2、timeout详解

默认是没有timeout参数的,一般情况想,当把所有的查询完成后,才会返回所有的请求数据。但是当某些需求必须要到几秒内返回数据,就设置timeout参数,当timeout时间到时,获取到几条参数,就会将数据立刻返回,后续数据继续处理。直至所有都返回。

3、timeout设置

  1. GET /bobotest/_search?timeout=1ms #1ms返回
  2. GET /bobotest/_search?timeout=1s #1秒返回