简体   繁体   English

如何限制magento elasticsearch索引的字段数

[英]How to limit number of fields in magento elasticsearch index

EDIT2: Was able to get over this error, but now have another one about mapper conflicts. EDIT2:能够克服这个错误,但现在有另一个关于映射器冲突的错误。 Apparently there already is some other mapper and it tries to update the field (?).显然已经有一些其他的映射器,它试图更新字段(?)。

I think I'll give up for now.我想我会暂时放弃。 Checked indices and they are full of fields again:检查索引,它们又充满了字段:

"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}


EDIT: Ok, as of now, I came to the index templates and such.编辑:好的,到现在为止,我来到了索引模板等。 Also got a little more knowledge about API and various options.还对 API 和各种选项有了更多了解。 Made a json as a payload to the PUT request, along with settings, analyzers, filters and so on.将 json 作为 PUT 请求的有效负载,以及设置、分析器、过滤器等。

Indeed, fields count after applying the template fell down to 684.实际上,应用模板后字段数下降到 684。

Main problem is an error while reindexing catalog search index:主要问题是重新索引目录搜索索引时出错:

Rejecting mapping update to [rcb2b_product_1_v2] as the final mapping would have more than 1 type: [_doc, document]"}]

It's elastic 7.13.1 and I am looking for an option to put in the right place to make it work...它是弹性的 7.13.1,我正在寻找一个选项来放置在正确的位置以使其工作......



I've got a problem with product index (which is in fact the only index in magento 2) being bloated to the point that it has over 34000 fields.我遇到了一个问题,产品索引(实际上是 magento 2 中的唯一索引)膨胀到超过 34000 个字段。 Site has over hundred of customer groups and over 40 countries/websites.网站拥有超过 100 个客户群体和 40 多个国家/网站。 Magento indexes prices (and a few other things) for any combination of them. Magento 为它们的任意组合索引价格(和其他一些东西)。

Now, trying to view indexes in kibana often fails, because of "limit exceeded" error.现在,尝试在 kibana 中查看索引经常会失败,因为“超出限制”错误。 This is problem number one, but problem number two is more generic - I'm just concerned about speed penalty for such a setup.这是第一个问题,但第二个问题更通用——我只是担心这种设置的速度损失。

Thought about some ways to solve the problem.想了一些解决问题的办法。 Even created static mapping with index set to false like this:甚至创建了索引设置为 false 的 static 映射,如下所示:

"dynamic_templates": [
        {
          "price_mapping": {
            "match": "price_*",
            "match_mapping_type": "string",
            "mapping": {
              "index": false,
              "store": true,
              "type": "double"
            }
          }
        },

but I suppose it would crash the site, not to mention that I don't even know yet how to apply it to constantly recreated indexes.但我想它会使站点崩溃,更不用说我什至还不知道如何将它应用于不断重新创建的索引。

Also thought about fixing kibana queries so that they would not expand automatically [*].还考虑修复 kibana 查询,使它们不会自动扩展 [*]。 No idea how to get to this either.也不知道如何做到这一点。

Last but not least, I could just set index.mapping.total_fields.limit to some absurd value and see what happens.最后但同样重要的是,我可以将 index.mapping.total_fields.limit 设置为一些荒谬的值,然后看看会发生什么。 It probably would not kill the site, but might kill kibana, if expanding queries come only from its side.它可能不会杀死该站点,但可能会杀死 kibana,如果扩展查询仅来自其一侧。

Well.出色地。 Any ideas?有任何想法吗?

There are multiple question and I tried to answer them one by one.有多个问题,我试着一一回答。

So, first, you need to use index templates to apply the mapping you created already to all indices related to product indices.因此,首先,您需要使用索引模板将您已经创建的映射应用于与产品索引相关的所有索引。 Also you can check using aliases for the product indices.您还可以使用产品索引的别名进行检查。 There is an option on aliases as is_write_index .别名上有一个选项is_write_index I think you need to check it, too.我想你也需要检查一下。

Second, there is a dynamic parameter for the properties of the mapping.其次,映射属性有一个dynamic参数。 And you can prevent adding the all fields to mapping even.你甚至可以阻止将所有字段添加到映射中。

https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html#dynamic-parameters https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic.html#dynamic-parameters

In the document, you can see that, there is a dynamic: false option there.在文档中,您可以看到,那里有一个dynamic: false选项。 This will ignore the fields.这将忽略这些字段。 But this means that you can not do a search on that fields.但这意味着您不能在该字段上进行搜索。 So, for example, you have object and there are so many fields inside this object and you are not using that fields in the search.因此,例如,您有 object 并且此 object 中有很多字段,并且您没有在搜索中使用这些字段。 You can use following mapping for this object to prevent adding that fields into mapping.您可以为此 object 使用以下映射,以防止将该字段添加到映射中。

PUT products
{
  "mappings": {
    "dynamic": false, 
    "properties": {
      "name": {
        "type": "text"
      },
      "extras": {
        "dynamic": false, 
        "properties": {}
      }
    }
  }
}

In this example, all the fields inside the extras object will be ignored to adding into mapping.在此示例中, extras object 中的所有字段将被忽略以添加到映射中。

Increasing the index.mapping.total_fields.limit configuration is a solution but I think we need to keep it low if there is a limit somewhere.增加index.mapping.total_fields.limit配置是一种解决方案,但我认为如果某处存在限制,我们需要将其保持在较低水平。 The limits means that Elasticsearch using much resource according to this limit when we increase it.限制意味着当我们增加它时,Elasticsearch 根据这个限制使用了多少资源。 Instead of, you can try to other solutions first.相反,您可以先尝试其他解决方案。 You can try to increase that limit if you don't find a solution in short.如果您找不到简短的解决方案,您可以尝试增加该限制。

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

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