I am using an elasticsearch:7.62 docker image for Magento 2.4.1 but I am facing an issue every few days that my products aren't showing on the front end with a message "We can't find products matching the selection."
in my logs I get
"[2020-11-17 10:54:50] main.CRITICAL: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [magento2_product_1]","resource.type":"index_or_alias","resource.id":"magento2_product_1","index_uuid":"_na_","index":"magento2_product_1"}],"type":"index_not_found_exception","reason":"no such index [magento2_product_1]","resource.type":"index_or_alias","resource.id":"magento2_product_1","index_uuid":"_na_","index":"magento2_product_1"},"status":404} {"exception":"[object] (Elasticsearch\\Common\\Exceptions\\Missing404Exception(code: 404): {\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [magento2_product_1]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_1\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_1\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [magento2_product_1]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_1\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_1\"},\"status\":404} at /var/www/vhosts/mydomain.co.uk/httpdocs/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:624)"} []"
Reindexing the products fixes the issue
The output of curl http://localhost:9299/_cluster/health?pretty
"cluster_name" : "docker-cluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 1,
"active_shards" : 1,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 1,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 50.0
in my logs I get
"[2020-11-17 10:54:50] main.CRITICAL: {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index [magento2_product_1]","resource.type":"index_or_alias","resource.id":"magento2_product_1","index_uuid":"_na_","index":"magento2_product_1"}],"type":"index_not_found_exception","reason":"no such index [magento2_product_1]","resource.type":"index_or_alias","resource.id":"magento2_product_1","index_uuid":"_na_","index":"magento2_product_1"},"status":404} {"exception":"[object] (Elasticsearch\\Common\\Exceptions\\Missing404Exception(code: 404): {\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [magento2_product_1]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_1\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_1\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index [magento2_product_1]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_1\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_1\"},\"status\":404} at /var/www/vhosts/mydomain.co.uk/httpdocs/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:624)"} []"
Reindexing the products fixes the issue
The output of curl http://localhost:9299/_cluster/health?pretty
"cluster_name" : "docker-cluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 1,
"active_shards" : 1,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 1,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 50.0