这个问题特别奇特!
发现过程:客户网站从2.3升级到2.4.2 p1版本,发现elasticsearch 正常,但是始终无法得到任何数据,重置并刷新索引也无效。
问题日志:
\"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 [image_label] in order to load field data by uninverting the inverted index. Note that this can use significant memory.\"}}},\"status\":400} at /www/wwwroot/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:632)"} []
因为客户这个站点是从M1升级过来的,一直无任何问题,本次升级到M2.4,PHP版本及其它均有所升级,一一排除问题所在
测试并未发现elasticsearch 7.12版本不兼容2.4.2 P1版本
测试php版本无任何影响
数据库版本无任何影响
主题及所使用的搜索扩展mageworx SearchSuiteAutocomplete 无对此无任何影响
估计的是搜索所使用的字段不符合要求,默认情况下,分层导航中只能使用某些类型的产品属性。它们是Yes/No, Dropdown, Multipleselect, 与Price。不能将任何其他类型的属性设置为“在分层导航中使用 ”。但是通过直接更改数据库中的is_filterableandis_filterable_in_search值来解决此限制是一种技术可能性。如果发生这种情况,并且将任何其他属性类型(如日期,文本等)设置为在分层导航中使用,则Elasticsearch 会引发异常。
为确保这种情况,您需要找出是否Yes/No, Dropdown, Multipleselect, 与Price以外的其他任何属性被设置为用于分层导航中。
操作指南:
1. 备份数据库
2. 执行SQL语句
UPDATE catalog_eav_attribute AS cea INNER JOIN eav_attribute AS ea ON ea.attribute_id = cea.attribute_idSET cea.is_filterable = 0, cea.is_filterable_in_search = 0WHERE (cea.is_filterable = 1 OR cea.is_filterable_in_search = 1) AND frontend_input NOT IN ('boolean', 'multiselect', 'select', 'price');
3. 重建索引
php bin/magento indexer:reindex catalogsearch_fulltext
4.删除所有缓存文件并重建缓存
php bin/magento cache:clean