zoukankan      html  css  js  c++  java
  • ES 深度分页

    三种方式

    1. from + size

    2. scroll

    3. search_after

    三者对比,各自的优缺点、适用场景

    实验(es version 7.7)

    1. 创建类型mapping
    PUT /studentv1
    {
      "mappings" : {
        "doc" : {
          "properties" : {
            "name" :  {"type" :  "text"},
             "classs" : {"type" :  "text"},
             "age" :  {"type" :  "integer"}
          }
        }
      }
    }
    

    报错

    {
      "error" : {
        "root_cause" : [
          {
            "type" : "mapper_parsing_exception",
            "reason" : "Root mapping definition has unsupported parameters:  [doc : {properties={classs={type=string}, name={type=text}, age={type=integer}}}]"
          }
        ],
        "type" : "mapper_parsing_exception",
        "reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [doc : {properties={classs={type=string}, name={type=text}, age={type=integer}}}]",
        "caused_by" : {
          "type" : "mapper_parsing_exception",
          "reason" : "Root mapping definition has unsupported parameters:  [doc : {properties={classs={type=string}, name={type=text}, age={type=integer}}}]"
        }
      },
      "status" : 400
    }
    

    出现这个的原因是,elasticsearch7默认不在支持指定索引类型,默认索引类型是_doc,如果想改变,则配置include_type_name: true 即可(这个没有测试,官方文档说的,无论是否可行,建议不要这么做,因为elasticsearch8后就不在提供该字段)。
    调整为

    DELETE  /studentv1
    PUT /studentv1
    {
      "mappings" : {
          "properties" : {
            "name" :  {"type" :  "text"},
              "age" :  {"type" :  "integer"},
             "class" : {"type" :  "text"}
           
          }
      }
    
    DELETE  /studentv2
    PUT /studentv2
    {
      "mappings" : {
          "properties" : {
             "uid" :  {"type" :  "integer"},
            "name" :  {"type" :  "text"},
              "age" :  {"type" :  "integer"},
             "class" : {"type" :  "text"}
           
          }
      }
    }
    POST /studentv1/_doc
    {
      "name":"ls",
      "age": 28,
      "class":"1-1"
    }
    
    GET /studentv1/_doc/zl7wBnkBSSB4rsMqoiB-
    
    GET /studentv1/_search
    {
      "query":{
        "match_all": {}
      }
    }
    
    POST /studentv2/_doc
    {
      "uid": 10000,
      "name":"ls",
      "age": 28,
      "class":"1-1"
    }
    
    GET /studentv2/_doc/CF7yBnkBSSB4rsMq-CFn
    
    GET /studentv2/_search
    {
      "query":{
        "match_all": {}
      }
    }
    

    参考

    1. https://www.cnblogs.com/hello-shf/p/11543453.html
  • 相关阅读:
    浅谈JS的数组遍历方法
    浅谈JavaScript函数重载
    随机数的组合问题(JavaScript描述)
    如何使用百度bae部署web项目
    阿里前端笔试总结
    有趣的JavaScript隐式类型转换
    CSS如何实现”右部宽度固定,左部自适应“的布局
    Nor Flash的理论性能
    python argparse:命令行参数解析详解
    rwcheck:为嵌入式设备设计的读写压测工具
  • 原文地址:https://www.cnblogs.com/zendwang/p/14699296.html
Copyright © 2011-2022 走看看