zoukankan      html  css  js  c++  java
  • elasticsearch查询时设置最大返回数 max_result_window | 限制字段总数超1000

    es默认最大返回数是10000,支持的最大返回数是2^31-1,也就是2147483647,不建议设置太大,query数据时size不要太大,总得考虑内存消耗的,设置了返回max后可以用分页获取, from:num_a, size:num_b,获取的就是num_a+1到num_a+num_b的数据。

    1.kibana

    下面是在kibana中设置最大返回数,需要针对具体某个index做设置,试过模糊设置,发现失败,dsl如下:

    PUT log-2021-04-13/_settings
    {
      "index": {
        "max_result_window": 2000000000
      }
    }
    

    如果返回确认-true,说明设置成功,当然也可以通过get请求查看:

    GET log-*/_settings
    

    下面是返回结果:

    # 设置最大返回数
    {
      "acknowledged" : true
    }
    
    # 查询index的设置
    {
      "log-2021-04-12" : {
        "settings" : {
          "index" : {
            "number_of_shards" : "1",
            "provided_name" : "log-2021-04-12",
            "max_result_window" : "2000000000",
            "creation_date" : "1618219829836",
            "number_of_replicas" : "0",
            "uuid" : "jfHvq7vaTiqoUreOYGrSWA",
            "version" : {
              "created" : "6070299"
            }
          }
        }
      },
      "log-2021-04-13" : {
        "settings" : {
          "index" : {
            "number_of_shards" : "1",
            "provided_name" : "log-2021-04-13",
            "max_result_window" : "2000000000",
            "creation_date" : "1618282080819",
            "number_of_replicas" : "0",
            "uuid" : "zt-kx98HSRy3_ZU-0Ye0iQ",
            "version" : {
              "created" : "6070299"
            }
          }
        }
      }
    }
    

    设置字段数

    PUT _all/_settings # 所有索引,也可以指定具体index
    {
      "index.mapping.total_fields.limit": 2000
    }
    

    2.python

    python代码实现:

    es = ElasticSearchClient.get_as_server() # 创建es连接
    max_result_body = {'index':{
                          'max_result_window':500000}}
    es.indices.put_settings(index='index_name', body=max_result_body)
    

    设置索引字段数
    类似返回最大一样,body内:

    {
      "index.mapping.total_fields.limit": 2000
    }
    
  • 相关阅读:
    自动化测试初介
    接口测试初介
    常见测试面试过程及及问题解析
    hadoop伪分布式平台组件搭建
    使用Github搭建个人博客
    centos7中redis安装配置
    Hive安装配置
    hadoop大数据组件启动
    Java生成窗口
    正则语法
  • 原文地址:https://www.cnblogs.com/davis12/p/14653166.html
Copyright © 2011-2022 走看看