1、es分页搜索语法

  1. GET /bobotest/_search?from=0&size=3 #一页,3条数据
  2. {
  3. "took" : 0,
  4. "timed_out" : false,
  5. "_shards" : {
  6. "total" : 1,
  7. "successful" : 1,
  8. "skipped" : 0,
  9. "failed" : 0
  10. },
  11. "hits" : {
  12. "total" : {
  13. "value" : 7,
  14. "relation" : "eq"
  15. },
  16. "max_score" : 1.0,
  17. "hits" : [
  18. {
  19. "_index" : "bobotest",
  20. "_type" : "_doc",
  21. "_id" : "1",
  22. "_score" : 1.0,
  23. "_source" : {
  24. "name" : "tian bo",
  25. "desc" : "ke ai",
  26. "age" : 11,
  27. "tags" : [
  28. "keai",
  29. "kuaile"
  30. ]
  31. }
  32. },
  33. {
  34. "_index" : "bobotest",
  35. "_type" : "_doc",
  36. "_id" : "5",
  37. "_score" : 1.0,
  38. "_source" : {
  39. "name" : "lisi",
  40. "desc" : "piaoliang de keai de xiaogege111",
  41. "age" : 15,
  42. "tags" : "shuaige"
  43. }
  44. },
  45. {
  46. "_index" : "bobotest",
  47. "_type" : "_doc",
  48. "_id" : "6",
  49. "_score" : 1.0,
  50. "_source" : {
  51. "name" : "lisi",
  52. "desc" : "piaoliang de keai de xiaogege111",
  53. "age" : 15,
  54. "tags" : "shuaige"
  55. }
  56. }
  57. ]
  58. }
  59. }

2、deeping page原理

image.png
排序通过_score分数进行排序

在搜索过深时,就需要在coordinate node上保存大量的数据,并且对大量数据进行排序,排序之后,在取出对应的那一页,这个过程,即耗费网络带宽,耗费内存,耗费cpu,所以deeping page有很大的性能问题