问题表象
错误日志大概为:
[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
通过搜索/复现和review该github,发现是因为magento默认的目录属性返回值是 double
, 而代码有问题,并没有配置double属性。
修复方式就是让Magento支持double属性
修复方式
文件位置:
vendor/magento/module-elasticsearch/etc/di.xml
增加double类型
<item name="double" xsi:type="object">Magento\Elasticsearch\SearchAdapter\Query\ValueTransformer\DoubleTransformer</item>
修复后:
<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