Resolving "Rejecting mapping update" issue in Magento 2.4.3
main.CRITICAL: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [magento2_product_1_v2] as the final mapping would have more than 1 type: [_doc, document]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [magento2_product_1_v2] as the final mapping would have more than 1 type: [_doc, document]"},"status":400} {"exception":"[object] (Elasticsearch\Common\Exceptions\BadRequest400Exception(code: 400): {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Rejecting mapping update to [magento2_product_1_v2] as the final mapping would have more than 1 type: [_doc, document]"}],"type":"illegal_argument_exception","reason":"Rejecting mapping update to [magento2_product_1_v2] as the final mapping would have more than 1 type: [_doc, document]"},"status":400} at /var/www/html/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:675)"}
Solution:
Indexing issues are likely caused by outdated Elasticsearch indexes.
1. Purge existing Elasticsearch indexes:
Before proceeding with the fix, it is recommended to clear all existing Elasticsearch indexes. This can be done using the following command:
php bin/magento indexer:reset catalog_product_attribute
2. Reindex your data:
Reindexing the data is crucial to ensure that the Elasticsearch indexes are generated with the correct mapping structure. Execute the following command to reindex your data:
php bin/magento indexer:reindex
3. Flush the Magento cache:
Clearing the Magento cache helps in ensuring that any cached indexes or settings are refreshed. Run the command below to flush the cache:
php bin/magento cache:flush
4. Verify and test:
After performing the above steps, verify if the "Rejecting mapping update" issue is resolved by running the catalog search and examining the logs.
If the error no longer occurs and the search functionality works as expected, the problem has been successfully resolved.
Conclusion:
Upgrading Magento 2 to version 2.4.3 and integrating Elasticsearch 7.10 can lead to mapping update issues that result in the "Rejecting mapping update" error.
By purging existing Elasticsearch indexes, reindexing the data, and flushing the Magento cache, this problem can be resolved.