简体   繁体   English

Elasticsearch 异常:已超出索引中的映射深度

[英]Elasticsearch exception : mappping depth in index has been exceeded

I have setup an Elasticsearch cluster on Bonsai.我在盆景上设置了一个 Elasticsearch 集群。 I am using elasticsearch-rest-high-level-client library to read Twitter-tweets stored in Kafka and push them to the Elasticsearch index.我正在使用elasticsearch-rest-high-level-client库来读取存储在 Kafka 中的 Twitter 推文并将它们推送到 Elasticsearch 索引。

I getting below exception: Exception in thread "main" ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=Limit of mapping depth [20] in index [twitter] has been exceeded due to object field [THIS CONTAINS ALL OF THE JSON MESSAGE RETRIEVED FROM KAFKA]我得到以下异常: Exception in thread "main" ElasticsearchStatusException[Elasticsearch exception [type=illegal_argument_exception, reason=Limit of mapping depth [20] in index [twitter] has been exceeded due to object field [THIS CONTAINS ALL OF THE JSON MESSAGE RETRIEVED FROM KAFKA]

It seems my code is trying to put all the message as a single field.看来我的代码正试图将所有消息作为一个字段。 What could be going wrong?可能出了什么问题?

IndexRequest indexRequest = new IndexRequest("twitter").source(jsonMessage, XContentType.JSON); IndexResponse indexResponse = restClient.index(indexRequest, RequestOptions.DEFAULT);

This error is about the depth of the Json you are trying to index.此错误与您尝试索引的 Json 的深度有关。 Default Mapping depth of 20 denotes that the Json you are trying to index can have fields going maximum of 20 levels deep.默认映射深度 20 表示您尝试索引的 Json 可以具有最多 20 级深度的字段。 For example例如

For example in below json, shippingAddress is 3 levels deep例如在下面的 json 中,shippingAddress 是 3 层深

{
"order": {
    "orderNo": "test_order",
    "orderDate": "2020-01-01",
    "customer": {
        "customerName": "John Doe",
        "customerPhone": "555-555-5555",
        "shippingAddress": {
            "addressLine1": "test",
            "addressLine2": "test",
            "city": "test",
            "state": "test",
            "country": "test"
        }
    }
}

} }

Try to optimize your document if possible.如果可能,请尝试优化您的文档。 If not, the setting can be updated if really required,如果没有,如果确实需要,可以更新设置,

index.mapping.depth.limit - The maximum depth for a field, which is measured as the number of inner objects. index.mapping.depth.limit - 字段的最大深度,以内部对象的数量来衡量。 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.例如,如果所有字段都定义在根 object 级别,则深度为 1。如果有一个 object 映射,则深度为 2,以此类推。默认为 20。

Check the documentation检查文档

https://www.elastic.co/guide/en/elasticsearch/reference/7.6/mapping.html#mapping-limit-settings https://www.elastic.co/guide/en/elasticsearch/reference/7.6/mapping.html#mapping-limit-settings

Similar issue I faced.我遇到的类似问题。 The fix was to provide the json as string instead of the actual json.修复是提供 json 作为字符串而不是实际的 json。 In this case instead of providing actual json object as jsonMessage, provide the plain string object of that json.在这种情况下,不要提供实际的 json object 作为 jsonMessage,而是提供该 Z466DEEC76ECDF2346D38571F6 的纯字符串 object。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM