Solved: Magento 2.4.x Elastic Search Error: Text Fields are Not Optimised for Operations
Hello Magento pals 😃
Ever faced an error in Magento that says: “Text Fields are Not Optimised for Operations”?
Magento continuously releases regular updates that add amazing features and enhance the store’s performance. However, sometimes these upgrades also come with some technical bugs that can hamper the store’s performance. One such elastic search bug in the Magento 2.4 release line is causing issues on the product category page. Many of the store owners reported the products aren’t loaded on the category page and the following error in the exception.log file is generated:
“Text fields are not optimized 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.”
In this blog post, I will provide a complete solution to solve this issue in Magento 2.4.x.
Method to Solve Magento 2.4.x Elastic Search Error: Text Fields are Not Optimised for Operations
In Magento 2.4.x, the product listing issue on the category page or the ‘Text fields are not optimized for operations’ error is caused when a varchar or text field is set to filterable in elastic search. This can be solved by finding the error-causing attribute and disabling the filterable in search for that attribute.
You can run the following query to find those attributes:
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')
Running the above query will list down all the varchar attributes that are set to ‘filterable in search’.
Once you find the attributes that are causing the ‘Text Fields are Not Optimized for Operations’ issue, you can disable them using the following query:
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')
Recently I posted a solution to cluster block exception in Magento 2, which you may also love to read.
If you have any doubts or queries, please feel free to comment. I’d be happy to help you. 😇
Also, I’d be grateful if you could share the solution with the Magento community via social media. 😊
Thank you. 🍀