[英]How to limit number of fields in magento elasticsearch index
EDIT2:能够克服这个错误,但现在有另一个关于映射器冲突的错误。 显然已经有一些其他的映射器,它试图更新字段(?)。
我想我会暂时放弃。 检查索引,它们又充满了字段:
"price_749_12":{"type":"double","store":true},"price_749_7":{"type":"double","store":true},"price_750_12":{"type":"double","store":true},"price_750_7":{"type":"double","store":true},"price_751_12":{"type":"double","store":true},"price_751_7":{"type":"double","store":true},"price_752_12":{"type":"double","store":true},"price_752_7":{"type":"double","store":true},"price_753_12":{"type":"double","store":true},"price_753_7":{"type":"double","store":true},"price_754_12":{"type":"double","store":true},"price_754_7":{"type":"double","store":true},"price_755_12":{"type":"double","store":true},"price_755_7":{"type":"double","store":true},"price_756_12":{"type":"double","store":true},"price_756_7":{"type":"double","store":true},"price_759_12":{"type":"double","store":true},"price_759_7":{"type":"double","store":true},"price_760_12":{"type":"double","store":true},"price_760_7":{"type":"double","store":true},"price_761_12":{"type":"double","store":true},"price_761_7":{"type":"double","store":true},"price_763_12":{"type":"double","store":true},"price_763_7":{"type":"double","store":true},"price_764_12":{"type":"double","store":true},"price_764_7":{"type":"double","store":true},"price_765_12":{"type":"double","store":true},"price_765_7":{"type":"double","store":true},"price_766_12":{"type":"double","store":true},"price_766_7":{"type":"double","store":true},"price_767_12":{"type":"double","store":true},"price_767_7":{"type":"double","store":true}
编辑:好的,到现在为止,我来到了索引模板等。 还对 API 和各种选项有了更多了解。 将 json 作为 PUT 请求的有效负载,以及设置、分析器、过滤器等。
实际上,应用模板后字段数下降到 684。
主要问题是重新索引目录搜索索引时出错:
Rejecting mapping update to [rcb2b_product_1_v2] as the final mapping would have more than 1 type: [_doc, document]"}]
它是弹性的 7.13.1,我正在寻找一个选项来放置在正确的位置以使其工作......
我遇到了一个问题,产品索引(实际上是 magento 2 中的唯一索引)膨胀到超过 34000 个字段。 网站拥有超过 100 个客户群体和 40 多个国家/网站。 Magento 为它们的任意组合索引价格(和其他一些东西)。
现在,尝试在 kibana 中查看索引经常会失败,因为“超出限制”错误。 这是第一个问题,但第二个问题更通用——我只是担心这种设置的速度损失。
想了一些解决问题的办法。 甚至创建了索引设置为 false 的 static 映射,如下所示:
"dynamic_templates": [
{
"price_mapping": {
"match": "price_*",
"match_mapping_type": "string",
"mapping": {
"index": false,
"store": true,
"type": "double"
}
}
},
但我想它会使站点崩溃,更不用说我什至还不知道如何将它应用于不断重新创建的索引。
还考虑修复 kibana 查询,使它们不会自动扩展 [*]。 也不知道如何做到这一点。
最后但同样重要的是,我可以将 index.mapping.total_fields.limit 设置为一些荒谬的值,然后看看会发生什么。 它可能不会杀死该站点,但可能会杀死 kibana,如果扩展查询仅来自其一侧。
出色地。 有任何想法吗?
有多个问题,我试着一一回答。
因此,首先,您需要使用索引模板将您已经创建的映射应用于与产品索引相关的所有索引。 您还可以使用产品索引的别名进行检查。 别名上有一个选项is_write_index
。 我想你也需要检查一下。
其次,映射属性有一个dynamic
参数。 你甚至可以阻止将所有字段添加到映射中。
https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html#dynamic-parameters
在文档中,您可以看到,那里有一个dynamic: false
选项。 这将忽略这些字段。 但这意味着您不能在该字段上进行搜索。 因此,例如,您有 object 并且此 object 中有很多字段,并且您没有在搜索中使用这些字段。 您可以为此 object 使用以下映射,以防止将该字段添加到映射中。
PUT products
{
"mappings": {
"dynamic": false,
"properties": {
"name": {
"type": "text"
},
"extras": {
"dynamic": false,
"properties": {}
}
}
}
}
在此示例中, extras
object 中的所有字段将被忽略以添加到映射中。
增加index.mapping.total_fields.limit
配置是一种解决方案,但我认为如果某处存在限制,我们需要将其保持在较低水平。 限制意味着当我们增加它时,Elasticsearch 根据这个限制使用了多少资源。 相反,您可以先尝试其他解决方案。 如果您找不到简短的解决方案,您可以尝试增加该限制。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.