Skip to content

Magento 2.4.7 ElasticSearch issue: Cannot search on field since it is not indexed

After upgrading from 2.3.7 to 2.4.6, using ES7, i now have constant ElasticSearch exceptions like this:

main.CRITICAL: ElasticsearchCommonExceptionsBadRequest400Exception:
{"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query: Cannot search on field [selection] since it is not indexed.","index_uuid":"CAWayfbETRej7ooLa5g2-w","index":"magento2_product_3_v42"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"magento2_product_3_v42","node":"bfqSffq8Q3C28mHdw3bGnQ","reason":{"type":"query_shard_exception","reason":"failed to create query: Cannot search on field [selection] since it is not indexed.","index_uuid":"CAWayfbETRej7ooLa5g2-w","index":"magento2_product_3_v42","caused_by":{"type":"illegal_argument_exception","reason":"Cannot search on field [selection] since it is not indexed."}}}]},"status":400}
in /vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:693

This field ‘selection’ is the only one that causes this issue.
Also if i do a reindex, it will fix the index for a few hours, and then the issue comes back.

I checked the elasticsearch node, and indeed the index is correct at first, but is somehow updated later on.

After reindexing:

        "selection" : {
          "type" : "keyword",
          "copy_to" : [
            "_search"
          ]
        },

But after a few hours:

        "selection" : {
          "type" : "keyword",
          "index" : false
        },

Anybody knows what is happening and how i can fix the issue for good?