• 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中的原生Ajax和JQuery中的Ajax
    this的用法
    static的特性
    时政20180807
    java compiler没有1.8怎么办
    Description Resource Path Location Type Java compiler level does not match the version of the installed Java project facet Unknown Faceted Project Problem (Java Version Mismatch)
    分词器
    [数算]有一个工程甲、乙、丙单独做,分别要48天、72天、96天完成
    一点感想
    解析Excel文件 Apache POI框架使用
  • 原文地址:https://www.cnblogs.com/zendwang/p/14699296.html
Copyright © 2020-2023  润新知