# 解决Magento2.3.x-2.4.x某些版本ES7错误

**URL:** https://forum.magentochina.org/t/%E8%A7%A3%E5%86%B3magento23x-24x%E6%9F%90%E4%BA%9B%E7%89%88%E6%9C%ACes7%E9%94%99%E8%AF%AF/1005
**Category:** Magento 2.X
**Tags:** 后端, elasticsearch, error
**Created:** [2023 年5 月 31 日 18:35 UTC](https://forum.magentochina.org/t/%E8%A7%A3%E5%86%B3magento23x-24x%E6%9F%90%E4%BA%9B%E7%89%88%E6%9C%ACes7%E9%94%99%E8%AF%AF/1005 "2023-05-31T18:35:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### 作者： ![Shuai](https://forum.magentochina.org/user_avatar/forum.magentochina.org/shuai/32/3_2.png) [@Shuai](https://forum.magentochina.org/u/Shuai)
#### 发布日期： [2023 年5 月 31 日 18:35 UTC](https://forum.magentochina.org/t/%E8%A7%A3%E5%86%B3magento23x-24x%E6%9F%90%E4%BA%9B%E7%89%88%E6%9C%ACes7%E9%94%99%E8%AF%AF/1005/1 "2023-05-31T18:35:05Z")

</div>

### 问题表象

错误日志大概为:  
`[2020-09-25 12:32:43] main.CRITICAL: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query: For input string: "114,190,192,448,465,467,468,470,473,474,478,481"","index_uuid":"W8u0kMu7Sw6M_AGdbIF4uw","index":"magento2_product_1_v8"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"magento2_product_1_v8","node":"KxBL7Iw8SV69LuPY3yto-A","reason":{"type":"query_shard_exception","reason":"failed to create query: For input string: "114,190,192,448,465,467,468,470,473,474,478,481"","index_uuid":"W8u0kMu7Sw6M_AGdbIF4uw","index":"magento2_product_1_v8","caused_by":{"type":"number_format_exception","reason":"For input string: "114,190,192,448,465,467,468,470,473,474,478,481""}}}]},"status":400} {"exception":"[object] (Elasticsearch\Common\Exceptions\BadRequest400Exception(code: 400): {"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query: For input string: \"114,190,192,448,465,467,468,470,473,474,478,481\"","index_uuid":"W8u0kMu7Sw6M_AGdbIF4uw","index":"magento2_product_1_v8"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"magento2_product_1_v8","node":"KxBL7Iw8SV69LuPY3yto-A","reason":{"type":"query_shard_exception","reason":"failed to create query: For input string: \"114,190,192,448,465,467,468,470,473,474,478,481\"","index_uuid":"W8u0kMu7Sw6M_AGdbIF4uw","index":"magento2_product_1_v8","caused_by":{"type":"number_format_exception","reason":"For input string: \"114,190,192,448,465,467,468,470,473,474,478,481\""}}}]},"status":400} at /home/ahogucak/www/ahogucak.myhostpoint.ch/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:632)"} []`

该错误报告出现于:

> /var/log/exception.log

类似的该错误，已经有人在github上发表了issues

> <https://github.com/magento/magento2/issues/30194>
>
> \### Preconditions (\*)
> 
> 1.Magento version 2.4.0
> 2.Elasticsearch version 7
> 
> \#…## Steps to reproduce (\*)
> 
> 1.After loading the page I am getting this error in exception log and system.log
> 2.
> 
> \### Expected result (\*)
> 
> 1. Page should be loaded without any error
> 2.
> 
> \### Actual result (\*)
> 
> 1. \[2020-09-25 12:32:43\] main.CRITICAL: {"error":{"root\_cause":\[{"type":"query\_shard\_exception","reason":"failed to create query: For input string: \\"114,190,192,448,465,467,468,470,473,474,478,481\\"","index\_uuid":"W8u0kMu7Sw6M\_AGdbIF4uw","index":"magento2\_product\_1\_v8"}\],"type":"search\_phase\_execution\_exception","reason":"all shards failed","phase":"query","grouped":true,"failed\_shards":\[{"shard":0,"index":"magento2\_product\_1\_v8","node":"KxBL7Iw8SV69LuPY3yto-A","reason":{"type":"query\_shard\_exception","reason":"failed to create query: For input string: \\"114,190,192,448,465,467,468,470,473,474,478,481\\"","index\_uuid":"W8u0kMu7Sw6M\_AGdbIF4uw","index":"magento2\_product\_1\_v8","caused\_by":{"type":"number\_format\_exception","reason":"For input string: \\"114,190,192,448,465,467,468,470,473,474,478,481\\""}}}\]},"status":400} {"exception":"\[object\] (Elasticsearch\\\\Common\\\\Exceptions\\\\BadRequest400Exception(code: 400): {\\"error\\":{\\"root\_cause\\":\[{\\"type\\":\\"query\_shard\_exception\\",\\"reason\\":\\"failed to create query: For input string: \\\\\\"114,190,192,448,465,467,468,470,473,474,478,481\\\\\\"\\",\\"index\_uuid\\":\\"W8u0kMu7Sw6M\_AGdbIF4uw\\",\\"index\\":\\"magento2\_product\_1\_v8\\"}\],\\"type\\":\\"search\_phase\_execution\_exception\\",\\"reason\\":\\"all shards failed\\",\\"phase\\":\\"query\\",\\"grouped\\":true,\\"failed\_shards\\":\[{\\"shard\\":0,\\"index\\":\\"magento2\_product\_1\_v8\\",\\"node\\":\\"KxBL7Iw8SV69LuPY3yto-A\\",\\"reason\\":{\\"type\\":\\"query\_shard\_exception\\",\\"reason\\":\\"failed to create query: For input string: \\\\\\"114,190,192,448,465,467,468,470,473,474,478,481\\\\\\"\\",\\"index\_uuid\\":\\"W8u0kMu7Sw6M\_AGdbIF4uw\\",\\"index\\":\\"magento2\_product\_1\_v8\\",\\"caused\_by\\":{\\"type\\":\\"number\_format\_exception\\",\\"reason\\":\\"For input string: \\\\\\"114,190,192,448,465,467,468,470,473,474,478,481\\\\\\"\\"}}}\]},\\"status\\":400} at /home/ahogucak/www/ahogucak.myhostpoint.ch/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:632)"} \[\]
> 2.
> 
> \---
> Please provide \[Severity\](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#backlog) assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
> 
> \- \[\] Severity: \*\*S0\*\* \_- Affects critical data or functionality and leaves users without workaround.\_
> \- \[\] Severity: \*\*S1\*\* \_- Affects critical data or functionality and forces users to employ a workaround.\_
> \- \[\] Severity: \*\*S2\*\* \_- Affects non-critical data or functionality and forces users to employ a workaround.\_
> \- \[\] Severity: \*\*S3\*\* \_- Affects non-critical data or functionality and does not force users to employ a workaround.\_
> \- \[\] Severity: \*\*S4\*\* \_- Affects aesthetics, professional look and feel, “quality” or “usability”.\_

通过搜索/复现和review该github，发现是因为magento默认的目录属性返回值是 `double`, 而代码有问题，并没有配置double属性。  
修复方式就是让Magento支持double属性

### 修复方式

文件位置:

> vendor/magento/module-elasticsearch/etc/di.xml

增加double类型

```xml
<item name="double" xsi:type="object">Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer\DoubleTransformer</item>

```

修复后:

```xml
    <type name="Magento\Elasticsearch\SearchAdapter\Query\ValueTransformerPool">
        <arguments>
                <argument name="valueTransformers" xsi:type="array">
                <item name="double" xsi:type="object">Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer\DoubleTransformer</item>
                <item name="default" xsi:type="object">Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer\TextTransformer</item>
                <item name="date" xsi:type="object">Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer\DateTransformer</item>
                <item name="float" xsi:type="object">Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer\FloatTransformer</item>
                <item name="integer" xsi:type="object">Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer\IntegerTransformer</item>
            </argument>
        </arguments>
    </type>

```

如果还没有解决该问题， 请尝试修改:

> vendor/magento/module-elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Converter.php

或者重新编译整个Magento2
