Elastic search

4 answers

Profile photo of ubdev Staff 97910.00 $tone July 9, 2021
Public

Hi Mik Herman, 
Please provide us more details about the issue you mentioned. We saw the ticket with the title ‘Elastic Search’ only. 
PS. Our apology for a certain delay in response since our team is off at the weekend. 
Regards,
Ubertheme team

#1
Profile photo of Mik Herman 110.00 $tone July 9, 2021
Public

Hi, sorry about that.

We used the PRO tool to migrate from Magento 1 to Magento 2.3. Now we migrated M2.3 to M2.4 and have problem with Elastic search. We consulted with the hosting provider and this is what they said:

“Whatever tool that was used to import the catalog did so in a way that was not fully compatible with Magento 2.
Magento 2 does not allow text fields to be filterable in the search results. Here are all of the attributes that are both text fields

MariaDB [col_coldev]> SELECT attribute_id, attribute_code FROM mgva_eav_attribute
    -> WHERE entity_type_id = 4 AND backend_type = 'varchar' AND attribute_id IN
    -> (SELECT attribute_id FROM mgva_catalog_eav_attribute WHERE (is_filterable_in_search=1 OR is_filterable=1));

+--------------+-------------------+
| attribute_id | attribute_code    |
+--------------+-------------------+
|          109 | image_label       |
|          127 | links_title       |
|          126 | samples_title     |
|          110 | small_image_label |
|          111 | thumbnail_label   |
+--------------+-------------------+

You’ll note the first one, “image_label” is the one being flagged as blocking the search results:

[2021-07-09 03:07:04] main.CRITICAL: {"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 [image_label] 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

The right fix is to re-import the data, only this time disallowing text fields from being filterable. (the hacky/kludgy “fix” would be to change the above attributes to no longer be filterable, reindex, and then hope for the best)

We cannot run the migration again because we have since changed the product categories and added a lot of products. Do you have any suggestion?

Thank you,

#2
Profile photo of Mall Staff 184060.00 $tone July 12, 2021
Public

Hi Mik Herman,
I am sorry for replying to you this late as our team has just been back from our weekend. 

We cannot run the migration again because we have since changed the product categories and added a lot of products. Do you have any suggestion?

You can edit those attributes to disable the ‘Filterable’ in the Attributes management in your backend at:
Stores > Attributes > Product (like an attribute in this screenshot: http://prntscr.com/1aev071)

Regards,
Mall.

#3
Profile photo of Mall Staff 184060.00 $tone July 12, 2021
Public

Hi Mik Herman,

Just want to share an alternate workaround, you can try these steps:

1. Run the following SQL query in your M2 DB to look for the attribute IDs that caused the errors with Elasticsearch that you mentioned:

SELECT attribute_id FROM mgva_eav_attribute WHERE entity_type_id = 4 AND backend_type IN ('varchar', 'tex') AND attribute_id IN (SELECT attribute_id FROM mgva_catalog_eav_attribute WHERE (is_filterable_in_search=1 OR is_filterable=1));

2. And then, you use the found attribute IDs to replace the condition in the ‘where’ clause in the following SQL query:

Update mgva_catalog_eav_attribute Set is_filterable_in_search = 0, is_filterable = 0 WHere attribute_id IN (YOUR_ATTRIBUTE_IDs);

3. Once done, reindex the data and clean the M2 cache, and let me to know how it goes.

Regards,
Mall.
 

#4

Please login or Register to Submit Answer

Written By

Comments