• 修改elasticsearch默认索引返回数


    1. 背景

    (1) 客户反映es查询只能返回10000个数据,而需求时返回1.9W个数据,因此需要设置对应索引的默认返回数index.max_result_window

    (2) 给客户部署的服务以docker-compose启动,其配置文件docker-compose.yml文件如下,其中es版本为5.6.16

    version: '2'
    services:
      aimind_mongodb:
        image: mongo
        container_name: aimind_mongodb
        volumes:
          - "/data/configdb/:/data/configdb"
          - "/data/db/:/data/db"
        restart: always
        ports:
          - "27017:27017"
      aimind_mysql:
        image: mysql
        container_name: aimind_mysql
        volumes:
          - "/root/aimind/mysql/data:/var/lib/mysql"
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: "test12345"
        ports:
          - "3306:3306"
      aimind_redis:
        image: redis
        container_name: aimind_redis
        command: redis-server --requirepass vagiahgi$$af
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: "test"
        ports:
          - "6379:6379"
      aimind_es_single:
        image: elasticsearch:5.6
        container_name: aimind_es_single
        ports:
          - "9300:9300"
          - "9200:9200"
        restart: always
        environment:
          - "discovery.type=single-node"
      aimind_backend:
        depends_on:
          - aimind_es_single
          - aimind_mongodb
        image: registry.iflyresearch.com/aimind/aimind-backend:devlatest
        command: java -jar /app.jar --spring.profiles.active=swagger,single
        container_name: aimind_backend
        environment:
        - "SPRING_PROFILES_ACTIVE=swagger,single"
        volumes:
          - "/root/aimind/storage:/root/aimind/storage"
          - "/var/run/docker.sock:/var/run/docker.sock"
          - "/root/aimind/docker/docker:/bin/docker"
          - "/root/aimind/aimind/application-single.yml:/home/aimind/application-single.yml"
          - "/mnt/cephfs/aimind/:/mnt/cephfs/aimind/"
        links:
          - aimind_es_single
          - aimind_mongodb
        extra_hosts:
          - "aimind-single:127.0.0.1"
          - "aimind_es:127.0.0.1"
        ports:
          - "18080:8080"
        restart: always
      aimind_web:
        depends_on:
          - aimind_backend
        image: registry.iflyresearch.com/aimind/aimind:devlatest
        container_name: aimind_web
        volumes:
          - "/root/aimind/aimind/web/nginx.conf:/etc/nginx/nginx.conf"
        links:
          - aimind_backend
        ports:
          - "18000:80"
        restart: always
    View Code

     2. 操作

    (1) es提供通过请求的方式更改指定index的_settings信息,因此可通过如下命令对索引aimind_prod_storage设置默认最大返回数量

    curl -XPUT localhost:9200/aimind_prod_storage/_settings -d '{"index.max_result_window":"100000"}'

    (2) 查询设置后

    curl -XGET localhost:9200/aimind_prod_storage/_settings

     (3) 为了避免docker-compose down/up重启,导致es的数据丢失,因此可以将es的数据文件保存在宿主机上,通过挂载的方式进行,具体配置如下:

    aimind_es_single:
        image: elasticsearch:5.6
        container_name: aimind_es_single
        ports:
          - "9300:9300"
          - "9200:9200"
        restart: always
        ulimits:
          memlock:
            soft: -1
            hard: -1
        volumes:
          - ./data:/usr/share/elasticsearch/data
        environment:
          - "discovery.type=single-node"
    View Code
  • 相关阅读:
    电机驱动MCU通用功能和技术点解析
    串行SPI NOR闪存VS并行NOR闪存
    非易失性存储器Flash和EEPROM之间的差异与优缺点
    为何要使用MCU
    MRAM实现对车载MCU中嵌入式存储器的取代
    ​弥补现有MRAM的不足
    将赛普拉斯nvSRAM替换为MRAM
    PSRAM在数据缓冲应用中可以取代SRAM或SDRAM
    数据库建表语句备份(二)
    数据库建表语句备份(一)
  • 原文地址:https://www.cnblogs.com/mengrennwpu/p/14517111.html
Copyright © 2020-2023  润新知