elasticsearch - 尝试批量索引时,ElasticSearch引发达到索引字段限制的情况

标签 elasticsearch

我正在使用以下python代码:

from elasticsearch import helpers, Elasticsearch
import csv

es = Elasticsearch(hosts="localhost:9200/")

with open('data.csv') as f:
    reader = csv.DictReader(f)
    helpers.bulk(es, reader, index='my-index', doc_type='my-type')
data.csv是具有5004个 header 和200万行(len(reader.fieldnames) = 5004)的csv。

当我运行此代码时,我得到:
[2018-10-30T12:20:59,448][DEBUG][o.e.a.b.TransportShardBulkAction] [my-index][3] failed to execute bulk item (index) BulkShardRequest [[my-index][3]] containing [101] requests    
java.lang.IllegalArgumentException: Limit of total fields [5500] in index [my-index] has been exceeded
        at org.elasticsearch.index.mapper.MapperService.checkTotalFieldsLimit(MapperService.java:580) ~[elasticsearch-6.4.2.jar:6.4.2]
        at org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:463) ~[elasticsearch-6.4.2.jar:6.4.2]
        at org.elasticsearch.index.mapper.MapperService.internalMerge(MapperService.java:355) ~[elasticsearch-6.4.2.jar:6.4.2]
    ...

我的索引设置:
{
    "my-index": {
        "settings": {
            "index": {
                "mapping": {
                    "total_fields": {
                        "limit": "5500"
                    }
                },
                "number_of_shards": "5",
                "provided_name": "my-index",
                "creation_date": "1540894469635",
                "number_of_replicas": "1",
                "uuid": "wl1k8NZRR7GUwfMCgwpPMQ",
                "version": {
                    "created": "6040299"
                }
            }
        }
    }
}

我真的不明白这一点,似乎一切都准备就绪,应该可以正常工作。

最佳答案

您遇到默认的ES "mapping explosion" protection.

似乎您已经知道要查询的设置,因为限制是5500,而不是默认值1000。请检查索引中的映射是否确实与csv结构匹配?到目前为止,似乎映射字段和csv header 的超集超过5500

关于elasticsearch - 尝试批量索引时,ElasticSearch引发达到索引字段限制的情况,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53062083/

相关文章:

elasticsearch - ElasticSearch根据找到短语的字段对文档进行排序

c# - 弹性NEST返回不一致的结果

php - 与 Elasticsearch 进行 AJAX 通信的流量和访问控制解决方案?

amazon-web-services - aws elasticsearch 身份验证错误并显示 403

mysql - 使用 elasticsearch-river-mysql 将数据从 MySQL 数据库流式传输到 Elasticsearch

elasticsearch - 使用 Spring-data-elasticsearch、ElasticsearchRepository 从 Elasticsearch 获取聚合信息

java - 使用 Java 获取 Amazon Elasticsearch 数据

java - Elasticsearch 使用 java api 返回原始 json

perl - 映射中的not_analyzed被忽略

lucene - 在 ElasticSearch 中匹配缺失的空格