[英]Elasticsearch exception : mappping depth in index has been exceeded
我在盆景上設置了一個 Elasticsearch 集群。 我正在使用elasticsearch-rest-high-level-client
庫來讀取存儲在 Kafka 中的 Twitter 推文並將它們推送到 Elasticsearch 索引。
我得到以下異常: 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]
看來我的代碼正試圖將所有消息作為一個字段。 可能出了什么問題?
IndexRequest indexRequest = new IndexRequest("twitter").source(jsonMessage, XContentType.JSON); IndexResponse indexResponse = restClient.index(indexRequest, RequestOptions.DEFAULT);
此錯誤與您嘗試索引的 Json 的深度有關。 默認映射深度 20 表示您嘗試索引的 Json 可以具有最多 20 級深度的字段。 例如
例如在下面的 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"
}
}
}
}
如果可能,請嘗試優化您的文檔。 如果沒有,如果確實需要,可以更新設置,
index.mapping.depth.limit - 字段的最大深度,以內部對象的數量來衡量。 例如,如果所有字段都定義在根 object 級別,則深度為 1。如果有一個 object 映射,則深度為 2,以此類推。默認為 20。
檢查文檔
https://www.elastic.co/guide/en/elasticsearch/reference/7.6/mapping.html#mapping-limit-settings
我遇到的類似問題。 修復是提供 json 作為字符串而不是實際的 json。 在這種情況下,不要提供實際的 json object 作為 jsonMessage,而是提供該 Z466DEEC76ECDF2346D38571F6 的純字符串 object。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.