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?


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

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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