Upgrade to Magento 2.4.6 and Elasticsearch results in elasticsearch error and no products on Category pages

Upgrade to Magento 2.4.6 and Elasticsearch results in elasticsearch error and no products on Category pages

July 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Upgrade to Magento 2.4.6 and Elasticsearch results in elasticsearch error and no products on Category pages

Upgrading Magento 2.4.6: Resolving Category Page Product Visibility Issues with Elasticsearch/Opensearch

We recently encountered an intriguing challenge when upgrading a client’s working store to the latest Magento 2.4.6 version and migrating from Elasticsearch to OpenSearch for improved performance and security. While individual product pages displayed perfectly, category pages remained stubbornly empty, despite showing the expected “We can’t find products matching the selection” message.

Initial Investigation: Prerequisites and Connection Verification

Our initial steps focused on confirming that all prerequisites were met before proceeding with the upgrade:

  • We ensured that PHP 7.4 or later was installed.
  • MySQL 8.0 or later (or MariaDB 10.2 or later) was verified as the database system.
  • The necessary extensions - SOAP, cURL, etc. - were enabled.

The connection to OpenSearch was successfully established upon following these steps:

php bin/magento app:config:import --all

However, despite our best efforts with the usual suspects (reindexing, deploying static content, flushing cache, compiling dependencies), the category pages remained frustratingly bare. The products were visible in the backend and assigned to their respective categories, yet refused to make an appearance on the frontend.

Diving into the Exception Log

Upon examining the exception log, we discovered a most enlightening error message:

{
  "exception": "[object] (OpenSearch\\Common\\Exceptions\\BadRequest400Exception(code: 400): {\"error\":{\"root_cause\":[{\"type\":\"x_content_parse_exception\",\"reason\":\"[1:107] [field_sort] failed to parse field [order]\"}],\"type\":\"x_content_parse_exception\",\"reason\":\"[1:107] [field_sort] failed to parse field [order]\",\"caused_by\":{\"type\":\"illegal_argument_exception\",\"reason\":\"No enum constant org.opensearch.search.sort.SortOrder.\"}},}\"status\":400
}

This error pointed us towards the root of our problem: a parsing issue with the field_sort in OpenSearch, specifically related to the order field.

Resolving the Parsing Issue

To resolve this issue, we needed to ensure that the field_sort in our OpenSearch configuration was correctly defined. In our case, the configuration file located at app/code/Magento/Elasticsearch/etc/opensource/opensearch/elasticsearch.php required an update.

We modified the field_sort section as follows:

'fields_sort' => [
    'position' => [
        'sort' => Sort::FULL,
        'field_sort' => [
            'order' => [
                'type'  => SortOrder::ASC,
                'boost' => 100.0
            ]
        ]
    ],
]

The key change was adding the type parameter to the order field, setting it to SortOrder::ASC. This ensured that OpenSearch could correctly parse and understand the sorting order.

Restoring Product Visibility

With this modification in place, we reindexed the data using these commands:

php bin/magento indexer:reset
php bin/magento indexer:status
php bin/magento indexer:reindex catalog_category_product

After reindexing and refreshing the cache with php bin/magento cache:flush, our category pages finally sprang to life, displaying all assigned products in their respective categories.

Conclusion

This upgrade experience highlighted the importance of meticulous configuration when migrating between search engines. While Magento 2.4.6 provides robust support for OpenSearch, understanding the underlying parsing requirements is essential for ensuring a smooth transition with no loss of data or functionality.

If you find yourself facing similar challenges, remember to:

  • Verify all prerequisites before proceeding with the upgrade.
  • Carefully examine exception logs for detailed error messages.
  • Ensure that your configuration files are correctly updated and reindexed post-modification.
Magento 2 Catalog Cache Indexing

Our network