2

I upgraded to 2.4.1 and elasticsearch, which I did not use before.

In my log I find the following error

"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true, "failed_shards":[{"shard":0,"index":"magento2_product_1_v4","node":"HVBmFhwfQK-VkdOPpT60-g","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 [features] in order to load field data by uninverting the inverted index. Note that this can use significant memory."}}], 

(this repeats 5+ times deep)

at vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:632

This seems to indicate it is not happy with the [features] attribute being a text field

Problem is, it is not a text field, it is a multiselect attribute with backend type varchar - I have just checked the attributes table to be sure! - so what is this error about? Also, I am not aware of aggregrating or sorting by that field anywhere, though as a multiselect field it is used in layered navigation. That's what they are designed for, no?

How should multiselect attributes be to work with layered navigation and elasticsearch?

2 Answers 2

3

I figured it out

This was a data migration caused bug, I should have remembered that data migration would incorrectly put the multiselect attributes in the text eav table not the varchar eav table - see https://github.com/magento/data-migration-tool/issues/646

I had copied my data to the right place but I had not cleared the wrong entries in the text eav table. Clearing these fixed my problem

2
  • But why such varchar as "name" (product name) can be searchable?
    – zhartaunik
    Jan 20, 2021 at 7:44
  • @zhartaunik varchars can be searched - it's text that causes bugs
    – iphigenie
    Feb 8, 2021 at 11:59
0

I also faced the same issue, did a lot of research and noticed that it was an issue with attribute sorting configuration, it is not enabled in PLP sorting. Because of this, it is not able to add data in elastic search and throwing error. So I have fixed the error via enabling it in PLP sort.

I hope this will help.

2
  • 1
    I am also getting the same error even if my attribute is not text filed. It is int. I researched a lot on this but did not found any solution. Could you please explain your answer a bit. What do you mean by PLP sorting and where do you have enabled it. Aug 30, 2022 at 12:20
  • You should enable attributes for sorting from the attribute edit section. Once you enable sorting please reindex and this issue will get fixed.
    – Nits
    Aug 31, 2022 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.