栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

ElasticSearch 几个比较实用的配置

ElasticSearch 几个比较实用的配置

ElasticSearch 几个比较实用的配置项 1、IK分词器插件安装

下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases

选择与自己ElasticSearch版本号一致的zip包进行下载

下载完后复制到ElasticSearch安装路径的plugins目录下,然后解压缩,因为解压后文件夹名字有点长,可以修改一下,一般大家都习惯性地修改为ik

然后就是分词字典配置

进入ik分词器路径下的config目录,修改IKAnalyzer.cfg.xml




	IK Analyzer 扩展配置
	
	a.dic;b.dic
	 
	
	
	
	
	

配置完后重启ES

2、查询超过10000条数据的分页

先看看报错

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Result window is too large, from + size must be less than or equal to: [10000] but was [10010]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "public_resource_master",
        "node" : "C38y1RXeTQKvLw8U0cgqWw",
        "reason" : {
          "type" : "illegal_argument_exception",
          "reason" : "Result window is too large, from + size must be less than or equal to: [10000] but was [10010]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."
        }
      }
    ],
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Result window is too large, from + size must be less than or equal to: [10000] but was [10010]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting.",
      "caused_by" : {
        "type" : "illegal_argument_exception",
        "reason" : "Result window is too large, from + size must be less than or equal to: [10000] but was [10010]. See the scroll api for a more efficient way to request large data sets. This limit can be set by changing the [index.max_result_window] index level setting."
      }
    }
  },
  "status" : 400
}

仔细阅读错误消息(This limit can be set by changing the [index.max_result_window] index level setting.)后,发现可以通过更改 [index.max_result_window] 索引级别设置来设置此限制。

PUT your_index_name/_settings
{
  "index": {
    "max_result_window": 1000000000 # 默认为10000,修改后立即生效,无须重启ES
  }
}
3、跨域设置
# 修改elasticsearch.yml文件,添加一下配置
http.cors.enabled: true
http.cors.allow-origin: "*"
# 
http.cors.allow-headers: Content-Type,Accept,Authorization, x-requested-with
4、开启远程访问
# 修改elasticsearch.yml配置文件,修改设置
network.host: 0.0.0.0
# 转发
transport.host: localhost
# TCP端口转发
transport.tcp.port: 9300
# http端口
http.port: 9200

注:开启远程访问后,防火墙也要开放9200端口入站规则,如果是阿里云服务器还要添加安全组规则

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/279788.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号