elasticsearch中默认最大字段数1000个,实际上500左右就可能出现错误。
- 精简业务字段
2.手动修改elasticsearch 字段
curl -i -H "Content-Type: application/json" -X PUT -d "{\"index.mapping.total_fields.limit\":\"2100\"}" http://127.0.0.1:9200/index/_settings/
3.将多个字段放入一个字段中
参考官方解释
https://www.elastic.co/guide/en/elasticsearch/reference/7.3/mapping.html#mapping-limit-settings
Settings to prevent mappings explosion
Defining too many fields in an index is a condition that can lead to a mapping explosion, which can cause out of memory errors and difficult situations to recover from. This problem may be more common than expected. As an example, consider a situation in which every new document inserted introduces new fields. This is quite common with dynamic mappings. Every time a document contains new fields, those will end up in the index’s mappings. This isn’t worrying for a small amount of data, but it can become a problem as the mapping grows. The following settings allow you to limit the number of field mappings that can be created manually or dynamically, in order to prevent bad documents from causing a mapping explosion:
index.mapping.total_fields.limit
The maximum number of fields in an index. Field and object mappings, as well as field aliases count towards this limit. The default value is 1000.
index.mapping.depth.limit
The maximum depth for a field, which is measured as the number of inner objects. For instance, if all fields are defined at the root object level, then the depth is 1. If there is one object mapping, then the depth is 2, etc. The default is 20.
index.mapping.nested_fields.limit
The maximum number of distinct nested mappings in an index, defaults to 50.
index.mapping.nested_objects.limit
The maximum number of nested JSON objects within a single document across all nested types, defaults to 10000.
index.mapping.field_name_length.limit
Setting for the maximum length of a field name. The default value is Long.MAX_VALUE (no limit). This setting isn’t really something that addresses mappings explosion but might still be useful if you want to limit the field length. It usually shouldn’t be necessary to set this setting. The default is okay unless a user starts to add a huge number of fields with really long names.
``
扩展知识:graylog
来源:oschina
链接:https://my.oschina.net/u/3422521/blog/4286743