M2奇葩小知识:elasticsearch搜索无结果及相关异常

作者:admi... 点击数: 0 收藏到会员中心
最后编辑时间: 2022-05-26 22:47

完整错误日志:

 main.CRITICAL: Elasticsearch\Common\Exceptions\BadRequest400Exception: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [samples_title] in order to load field data by uninverting the inverted index. Note that this can use significant memory."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"moem_product_8_v4","node":"TWVRx3moTheJeTIBQ0d5tg","reason":{"type":"illegal_argument_exception","reason":"Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [samples_title] in order to load field data by uninverting the inverted index. Note that this can use significant memory."}}],"caused_by":{"type":"illegal_argument_exception","reason":"Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [samples_title] in order to load field data by uninverting the inverted index. Note that this can use significant memory.","caused_by":{"type":"illegal_argument_exception","reason":"Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [samples_title] in order to load field data by uninverting the inverted index. Note that this can use significant memory."}}},"status":400} in /www/wwwroot/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:693
付费内容限时免费中...

这种情况的来源

https://support.magento.com/hc/en-us/articles/360027356612-Elasticsearch-5-is-configured-but-search-page-does-not-load- with-Fielddata-is-disabled-error

默认情况下,分层导航中只能使用某些类型的产品属性。它们是 Yes/No、Dropdown、Multipleselect 和 Price。这就是为什么在 Magento 后台时,您不能将任何其他类型的属性设置为在分层导航中使用 及可过滤或在搜索结果分层导航中使用 。但是通过直接更改数据库中的 is_filterable 和 is_filterable_in_search 值,有一种技术上的可能性可以绕过这个限制。而老版本MAGENTO1及MAGENTO2.3部分属性是可以这样子设置的,这就导致了在升级或是更新后,无法以正常在新版本,比如2.4.3/2.4.4等等中正常可用


进入数据库管理。运行

select * from catalog_eav_attribute WHERE is_filterable_in_search = 1 and attribute_id IN (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = 4 AND backend_type = 'varchar')

查询出有哪些属性值是设定的,这里的 `attribute_code` 要记下。

比如

image_label

smallimage_label

label_title

sample_title


is_filterable_in_search=1

再批量设定成 0

UPDATE catalog_eav_attribute 
SET is_filterable_in_search = 0 
WHERE attribute_id IN (SELECT attribute_id FROM eav_attribute WHERE entity_type_id = 4 AND backend_type = 'varchar')


执行查询

SELECT * FROM eav_attribute where attribute_code = "sample_title";  //替换成你上面记录的`attribute_code`

更新掉它

UPDATE eav_attribute SET is_filterable_in_search = 0 WHERE attribute_code = "sample_title";



热点标签: 搜索无结果 elasticsearch
内容说明:
如您需要转载本文请保留以下信息是对作者发文的支持与尊重:

M2奇葩小知识:elasticsearch搜索无结果及相关异常 来源于 https://www.magentola.com/news-read-305.html
上一篇:M2奇葩小知识:后台用户管理里面无用户
下一篇:M2如何在不影响访问的情况下禁止原始图片被访问及下载
相关内容
产品推荐