• ElasticSearch(十五) _search api 分页搜索及deep paging性能问题


    1、分页搜索

    语法:

    size,from
    
    GET /_search?size=10
    GET /_search?size=10&from=0
    GET /_search?size=10&from=20
    GET /index/type/_search
    {
      "query": { "match_all": {} },
      "from": 1,
      "size": 1
    }

    实际操作:

    查看共有5条数据:

    GET /test_index/test_type/_search
    "hits" : {
        "total" : 7,
        "max_score" : 1.0,

    我们假设将这7条数据分成3页,每一页是3条数据,来实验一下这个分页搜索的效果

    第一页:

    GET /test_index/test_type/_search?from=0&size=3
    
    {
      "took" : 1,
      "timed_out" : false,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : 7,
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "test_index",
            "_type" : "test_type",
            "_id" : "10",
            "_score" : 1.0,
            "_source" : {
              "test_field1" : "test1",
              "test_field2" : "test2"
            }
          },
          {
            "_index" : "test_index",
            "_type" : "test_type",
            "_id" : "12",
            "_score" : 1.0,
            "_source" : {
              "num" : 1,
              "tags" : [ ]
            }
          },
          {
            "_index" : "test_index",
            "_type" : "test_type",
            "_id" : "6",
            "_score" : 1.0,
            "_source" : {
              "test_field" : "test test"
            }
          }
        ]
      }
    }

    第二页:

    GET /test_index/test_type/_search?from=3&size=3
    
    {
      "took" : 7,
      "timed_out" : false,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : 7,
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "test_index",
            "_type" : "test_type",
            "_id" : "2",
            "_score" : 1.0,
            "_source" : {
              "test_field" : "replaced test2"
            }
          },
          {
            "_index" : "test_index",
            "_type" : "test_type",
            "_id" : "Baq9WWgBjIP9BXE3vrJ2",
            "_score" : 1.0,
            "_source" : {
              "test_field" : "auto-generate id test"
            }
          },
          {
            "_index" : "test_index",
            "_type" : "test_type",
            "_id" : "1",
            "_score" : 1.0,
            "_source" : {
              "test_field1" : "test1",
              "test_field2" : "bulk test1"
            }
          }
        ]
      }
    }

    第三页:

    GET /test_index/test_type/_search?from=6&size=3
    
    {
      "took" : 1,
      "timed_out" : false,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "skipped" : 0,
        "failed" : 0
      },
      "hits" : {
        "total" : 7,
        "max_score" : 1.0,
        "hits" : [
          {
            "_index" : "test_index",
            "_type" : "test_type",
            "_id" : "11",
            "_score" : 1.0,
            "_source" : {
              "num" : 0,
              "tags" : [ ]
            }
          }
        ]
      }
    }

    2、深度搜索deep paging的性能问题

     

  • 相关阅读:
    Linux下运行java项目
    Matlab 绘图完整入门
    Matlab命令合集 妈妈再也不用担心我不会用matlab了
    详尽全面的matlab绘图教程
    拉格朗日乘子法 那些年学过的高数
    【转】几款网络仿真软件的比较
    正则表达式30分钟入门教程 ——堪称网上能找到的最好的正则式入门教程
    并发编程详细整理
    高并发通信模型NIO
    Java并发编程的艺术笔记(九)——FutureTask详解
  • 原文地址:https://www.cnblogs.com/ql211lin/p/10287747.html
Copyright © 2020-2023  润新知