zoukankan      html  css  js  c++  java
  • 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的性能问题

     

  • 相关阅读:
    atom 震动特效
    CSRF和XSS
    解决remove @override annotation(jdk1.5和jdk1.6)
    JDK 工具列表
    解决Win10系统backgroundTaskHost占用cpu大
    ideaIU-15.0.2 注册码
    jprofiler_windows-x64_9_1注册码
    修改ligerui 默认确认按钮
    解决 在POM配置Maven plugin提示错误“Plugin execution not covered by lifecycle configuration”
    安装 Flex2packagebeta_1.994
  • 原文地址:https://www.cnblogs.com/ql211lin/p/10287747.html
Copyright © 2011-2022 走看看