首页 > 其他 > 详细

修改elasticsearch默认索引返回数

时间:2021-03-11 17:16:31      阅读:42      评论:0      收藏:0      [点我收藏+]

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) 为了避免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

 

aimind_prod_storage

修改elasticsearch默认索引返回数

原文:https://www.cnblogs.com/mengrennwpu/p/14517111.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!