• 基于Elasticsearch开发时的注意事项备忘


    记录一些自己在Elasticsearch开发过程的琐碎知识点

    1、使用ScriptFields时,需在yml配置文件中添加配置(script.disable_dynamic: false)开启动态脚本支持,好像是从某个版本以上才需要,反正我用的1.5.2是需要这个配置的。

    2、创建索引时,适当调整mapping设置,提高索引效率,如关闭副本,创建完索引后重新设置副本数量即可:NumberOfReplicas(0)

    3、创建索引时,批量提交数据,可以大大提高索引效率,如:BulkIndexOperation

    4、只需要查询记录条数的时候,添加参数:search_type=count  ,Nest中是SearchType.Count。只返回记录条数,不返回具体数据,提高查询性能

    5、Elasticsearch配置LDAP身份认证(searchguard)后,请求时需传入用户身份信息,实现方式:

        curl请求:curl -XGET -u用户名:密码  192.168.xx.xx:9200

        Http请求(Nested):http://用户名:密码@192.168.xx.xx:9200

    6、部署linux机器,调整系统同时打开的文件数量:ulimit -n 65536(只针对当前会话生效);
         永久生效:vi /etc/security/limits.conf

         * soft nproc 65536
         * hard nproc 65536
         * soft nofile 65536
         * hard nofile 65536

    7、可适当调整Elasticsearch线程池大小

         官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-threadpool.html

         查看当前线程池配置:http://192.168.xxx.xxx:9200/_nodes/thread_pool/

         调整原因:Elasticsearch供search的默认线程池数量为1000,当出现大GC导致search请求阻塞时,会导致线程池不足,进而拒绝请求,导致前端请求堆积。异常信息如下:

          Failed to execute fetch phase
         org.elasticsearch.common.util.concurrent.EsRejectedExecutionException: rejected execution (queue capacity 1000) on
          org.elasticsearch.search.action.SearchServiceTransportAction

     8、Elasticsearch各版本发版记录:https://www.elastic.co/guide/en/elasticsearch/reference/current/es-release-notes.html

          关注Elasticsearch各版本升级所发生的变化,提供的新功能等

     9、使用GeoPoint地理检索时,赋值时需注意,Latitude代表纬度,Longitude代表经度,百度地图中获取到的坐标一般是(经度,纬度),传入值错误的话,在1.5.2版本中系统没有报错,未做经度和纬度值的有效性校验,在ES2.x版本,默认会做数据校验,经度有效数据范围为[-180,180],纬度有效数据范围为[-90,90]

  • 相关阅读:
    设计模式之简单工厂模式
    设计模式之工厂方法模式
    设计模式之抽象工厂模式
    面向对象设计原则
    Spring与Struts整合
    Spring与Hibernate、Mybatis整合
    Java中执行外部命令
    Spring3之Security
    综合练习:词频统计
    组合数据类型综合练习
  • 原文地址:https://www.cnblogs.com/lijunhao/p/5341604.html
Copyright © 2020-2023  润新知