3

I'm facing an issue with a fresh install of Magento 2.4.1 and Elasticsearch 7.6.2. The products appear for a moment, and I have to reindex again to see them.

The main issue appears to be "No mapping found for [position_category_xxxx] in order to sort on"

[2020-10-31 08:15:23] main.CRITICAL: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [position_category_12] in order to sort on","index_uuid":"AWmVw6XqQsikmOu6IfXvNg","index":"magento2_product_1_v4"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"magento2_product_1_v4","node":"2Nx7OzfeT8OB1JixlyNJng","reason":{"type":"query_shard_exception","reason":"No mapping found for [position_category_12] in order to sort on","index_uuid":"AWmVw6XqQsikmOu6IfXvNg","index":"magento2_product_1_v4"}}]},"status":400} {"exception":"[object] (Elasticsearch\\Common\\Exceptions\\BadRequest400Exception(code: 400): {\"error\":{\"root_cause\":[{\"type\":\"query_shard_exception\",\"reason\":\"No mapping found for [position_category_12] in order to sort on\",\"index_uuid\":\"AWmVw6XqQsikmOu6IfXvNg\",\"index\":\"magento2_product_1_v4\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[{\"shard\":0,\"index\":\"magento2_product_1_v4\",\"node\":\"2Nx7OzfeT8OB1JixlyNJng\",\"reason\":{\"type\":\"query_shard_exception\",\"reason\":\"No mapping found for [position_category_12] in order to sort on\",\"index_uuid\":\"AWmVw6XqQsikmOu6IfXvNg\",\"index\":\"magento2_product_1_v4\"}}]},\"status\":400} at /var/www/vhosts/mywebsite.com/httpdocs/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:632)"} []

It's a clean install without any extension or custom theme. Elasticsearch is running on a Docker container / Plesk. (3 nodes cluster). I have 4 Magento 2.4.1 websites on the server.

4
  • are you still facing this issue? I was wondering whether you found any solution? I have the problem...Thanks.
    – Viktor
    Commented Dec 29, 2020 at 11:08
  • Yes, it’s happening when you have multiple magento websites on the same server. You need to specify a different elastic search index name for each website. Go to Stores/Configuration/Catalog/Catalog/ Elastic index prefix - and specify a different index name for each website. Then reindex each store and it will work. Commented Dec 30, 2020 at 12:05
  • Try searching for "position_category_12" in your custom code. This is related to Toolbar options I believe. You might have some custom toolbar sorting. Commented Aug 18, 2021 at 19:11
  • Hey, Dali Abassi, Once do reset the indexer using command php bin/magento indexer:reset run indexing command php bin/magento indexer:reindex Commented Aug 13 at 13:33

5 Answers 5

4

Run bin/magento indexer:reindex from your root directory folder.

1
  • 4
    If bin/magento indexer:reindex doesn't solve the issue then. Please bin/magento indexer:reset then bin/magento indexer:reindex Commented Aug 9, 2021 at 11:07
0

We have the same issue and have not been able to find a solution for this anywhere. It is such a strange error. We have ElasticSearch7 installed with Magento 2.3.5pt-2 and we get very similar error.

Running bin/magento indexer:reindex is only a temporary fix and not a solution to the problem. Error will come back and products disappear on frontend of site.

main.CRITICAL: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"No mapping found for [news_to_date.sort_news_to_date] in order to sort on","index_uuid":"v6RZUm3kQEugC3aecGVp1Q","index":"magento2live_webpos_productsearch_fulltext_1_v17"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"magento2live_webpos_productsearch_fulltext_1_v17","node":"Ml8-bmNiSkqu5yLzk8on9g","reason":{"type":"query_shard_exception","reason":"No mapping found for [news_to_date.sort_news_to_date] in order to sort on","index_uuid":"v6RZUm3kQEugC3aecGVp1Q","index":"magento2live_webpos_productsearch_fulltext_1_v17"}}]},"status":400} {"exception":"[object] (Elasticsearch\\Common\\Exceptions\\BadRequest400Exception(code: 400): {\"error\":{\"root_cause\":[{\"type\":\"query_shard_exception\",\"reason\":\"No mapping found for [news_to_date.sort_news_to_date] in order to sort on\",\"index_uuid\":\"v6RZUm3kQEugC3aecGVp1Q\",\"index\":\"magento2live_webpos_productsearch_fulltext_1_v17\"}],\"type\":\"search_phase_execution_exception\",\"reason\":\"all shards failed\",\"phase\":\"query\",\"grouped\":true,\"failed_shards\":[{\"shard\":0,\"index\":\"magento2live_webpos_productsearch_fulltext_1_v17\",\"node\":\"Ml8-bmNiSkqu5yLzk8on9g\",\"reason\":{\"type\":\"query_shard_exception\",\"reason\":\"No mapping found for [news_to_date.sort_news_to_date] in order to sort on\",\"index_uuid\":\"v6RZUm3kQEugC3aecGVp1Q\",\"index\":\"magento2live_webpos_productsearch_fulltext_1_v17\"}}]},\"status\":400} at /var/www/vhosts/upperlimitsinc.com/httpdocs/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:641)"} []
1
  • After updating to Magento2.4.2pt-1. We do not receive this error anymore.
    – Jonathan
    Commented Oct 28, 2021 at 18:01
0

This can be resolved by adding '"unmapped_type": "type_of_field"'

You can get the type of field from the Query Body.

From Elasticsearch Documentation,

By default, the search request will fail if there is no mapping associated with a field. The unmapped_type option allows you to ignore fields that have no mapping and not sort by them. The value of this parameter is used to determine what sort values to emit. Here is an example of how it can be used:
POST /_search
{
  "sort" : [
    { "price" : {"unmapped_type" : "long"} }
  ],
  "query" : {
    "term" : { "product" : "chocolate" }
  }
}

Alternatively, you could dig into the type that is causing the error and add the mapping manually or create a document that has the field if you have dynamic mapping.

0

I fixed this issue by executing this command

bin/magento indexer:reindex catalogsearch_fulltext
-1

I solved this problem by changing sorting in categories by "Name". And i saw that somebody fix this by changing prefix, but it's global https://prnt.sc/whqf1p

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.