我在ES上收到以下错误:
[Elasticsearch exception [type=illegal_argument_exception, reason=Limit of total fields [1000] in index [<index_name>] has been exceeded]]
我不想增加字段大小,因为它可能导致内存爆炸。经过大量关于堆栈溢出的解决方案后,我发现我们需要创建一个备份索引,如下所示:
PUT /<dest_index>
现在,我需要将现有索引中的数据复制到上面创建的新索引中,同时删除不需要的字段。
所以,我尝试了这个:
创建了一个删除字段的管道:
PUT _ingest/pipeline/removePropertyMap
{
"description": "Removes the 'propertyMap' field",
"processors": [
{
"remove": {
"field" : "propertyMap"
}
}
]
}
而且,我正在复制这样的数据:
POST _reindex
{
"source": {
"index": "<source_index>"
},
"dest": {
"index": "<dest_index>",
"pipeline": "removePropertyMap"
}
}
在此之后,我仍将propertyMap作为新索引的映射中的一个字段。
我通过以下方式检查映射:
GET <dest_index>/_mapping
现在,我要删除的字段如下所示:
"project": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"properties": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"propertyMap": {
"properties": {
"90001": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
{
...
}
}
}
这是相同的文档结构:
{
"<index>": {
"mappings": {
"_doc": {
"properties": {
"propertyMap": {
"properties": {
"field1": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"field2": {
"properties": {
"anotherField": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
}
}
}
}
在属性内部,还有大量其他字段,与字段1和字段2相同。
我在这方面做错了什么?
最佳答案
我不太熟悉管道,但作为一种替代解决方案,您是否考虑过相反的方法(指定要保留的字段)?
POST _reindex
{
"source": {
"index": "<source_index>",
"_source": ["keep_field_1", "keep_field_2"]
},
"dest": {
"index": "<dest_index>"
}
}
该列表可能要长得多,因为您的字段数限制在1000个左右,但是您应该可以从映射中相对轻松地获得它。
关于amazon-web-services - 从ES中删除字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58858836/