[BUG]Elasticsearch - sorting by price ascending / descending throws error 500
Current Behavior
When Elasticsearch is enabled and you want to sort the listing by price in descending or ascending order, a 500 error is thrown. Elasticsearch logs the following:
[2025-07-04T06:20:52.253626+00:00] elasticsearch.CRITICAL: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [price.c_b7d2554b0ce847cd82f3ac9bd1c0dfca.gross] in order to sort on","index_uuid":"yqMLnLWHROeeDEjLA6fY3w","index":"sw6_product_1751592601"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"sw6_product_1751592601","node":"bOa3juslQW6q98MlfU_f_A","reason":{"type":"query_shard_exception","reason":"No mapping found for [price.c_b7d2554b0ce847cd82f3ac9bd1c0dfca.gross] in order to sort on","index_uuid":"yqMLnLWHROeeDEjLA6fY3w","index":"sw6_product_1751592601"}}]},"status":400} [] []
In the database, variant items do not have a price if they inherit it from the parent product. In my opinion, this causes the error.
Expected Behavior
Sort the products by the price of there parent products.
Steps To Reproduce
- setup elastic search
- add products with variants that inherit prices of their parents
- sort listing by price
Anything else?
No response
hey @digitalwert-devs is the issue still valid? provide some details to allow us to reproduce:
- env you set it up (docker, devenv, or cloud)
- version of backend and opensearch/elasticsearch
- the request's payload that causes HTTP 500 error