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的性能问题

     

  • 相关阅读:
    NPM (node package manager) 入门
    win10 环境 gitbash 显示中文乱码问题处理
    javascript中的Array对象 —— 数组的合并、转换、迭代、排序、堆栈
    Javascript 的执行环境(execution context)和作用域(scope)及垃圾回收
    Centos 下 mysql root 密码重置
    执行 $Gulp 时发生了什么 —— 基于 Gulp 的前端集成解决方案(二)
    Java I/O输入输出流详解
    反射---Java高级开发必须懂的
    细说Java多线程之内存可见性
    全面解析java注解
  • 原文地址:https://www.cnblogs.com/ql211lin/p/10287747.html
Copyright © 2011-2022 走看看