wangxinyun1995 / blogs

用issue记录我的博客
0 stars 0 forks source link

Elasticsearch默认fields1000报错解决 #3

Open wangxinyun1995 opened 5 years ago

wangxinyun1995 commented 5 years ago

解决方案: 说明:对于已经建立的索引可以通过设置fields进行修复,对于之后的将建立的索引通过设置template进行设置 yourEShost:port本地开发一般是 localhost:9200

对于已经建立的索引

curl -XPUT yourEShost:port/your_index_name/_settings -d '{"index.mapping.total_fields.limit": 0}'
#以上表示对于‘your_index_name’这个索引设置fields为无限制,默认为1000
curl -XPUT yourEShost:port/*/_settings -d '{"index.mapping.total_fields.limit": 50000}'
#这个表示对所有index的fields的limit设置为50000
curl yourEShost:port/_cat/indices/*?pretty
#查看所有索引,查看指定索引将*换为索引名称即可
curl -XGET yourEShost:port/_all/_settings?pretty
#查看所有索引的设置
curl yourEShost:port/bilogs-logics-202.2017.11.21/_settings?pretty
#查看单个索引的设置
curl yourEShost:port/bilogs-logics-202.2017.11.23/_mapping?pretty
#查看单个索引的map

对于未创建的索引,可以通过模板设置

curl -XPUT 'yourEShost:port/_template/all ' -d '
{
  "template": "*",
  "settings": {
    "index.mapping.total_fields.limit": 50000,
    "refresh_interval": "30s"
  }
}'
#数据量比较大,数字建议设置大一点
#设置template的setting,
curl -XGET yourEShost:port/_template/*?pretty
#查看所有模板的设置,使用了*匹配,如果看指定的模板将*换成对应模板名即可,另外这里可以看到每个模本都有一个"order"字段,这个字段的数值越低,优先级越高,优先级高的模板会覆盖优先级低的模板