我正在处理一个巨大的 json blob,所以我需要打开密封。如何将elasticsearch设置index.mapping.total_fields.limit为无限制?
您不能将其设置为无限制。事实上,它已经被有意限制,以防止映射爆炸。您可以在此处阅读github 问题。
实现您想要的唯一方法是使用高值。
您可以在创建索引时指定该值:
PUT test
{
"shopfront": {
"index.mapping.total_fields.limit": 2000,
"number_of_shards": 5,
"number_of_replicas": 2
},
"mappings": {
...
}
}
Run Code Online (Sandbox Code Playgroud)
或者,如果是针对现有索引:
PUT shopfront/_settings
{
"index.mapping.total_fields.limit": 2000
}
Run Code Online (Sandbox Code Playgroud)
我认为当前的实现不允许您将此值设置为无限制。
正如您可能知道的那样,默认值已经很高(1000),如官方文档中所述。
如果您检查源代码,您可以看到当前的实现不允许无限制(例如设置为-1),正如您在以下取自官方elasticsearch源代码的代码片段中看到的那样:
private void checkTotalFieldsLimit(long totalMappers) {
long allowedTotalFields = indexSettings.getValue(INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING);
if (allowedTotalFields < totalMappers) {
throw new IllegalArgumentException("Limit of total fields [" + allowedTotalFields + "] in index [" + index().getName() + "] has been exceeded");
}
}
Run Code Online (Sandbox Code Playgroud)
我相信您最好的选择是在映射索引时将其设置为非常高的值,并检查开销是否适合您的用例。
| 归档时间: |
|
| 查看次数: |
14273 次 |
| 最近记录: |