Magento 2.4.2 Elasticsearch Error: main.CRITICAL: {“error”:{“root_cause”:[{“type”:“query_shard_exception”,“reason”:"failed to create query

magento.stackexchange https://magento.stackexchange.com/questions/336268

Question

Elasticsearch not working with main.CRITICAL: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query. I have tested the connection in the backend and it's showing successfull. But on the front-end in the catalog search, no result is showing. I have checked in exception.log and the following error is showing:

main.CRITICAL: {"error":{"root_cause":[{"type":"query_shard_exception","reason":"failed to create query:
{ "bool" : { "must" : [ { "terms" : { "visibility" : [ "3", "4" ], "boost" : 1.0 } } ], "should" : [ { "match" : { "_search" : { "query" : "sams sams", "operator" : "OR", "prefix_length" : 0, "max_expansions" : 50, "fuzzy_transpositions" : true, "lenient" : false, "zero_terms_query" : "NONE", "auto_generate_synonyms_phrase_query" : true, "boost" : 2.0 } } }, { "match" : { "name" : { "query" : "sams sams", "operator" : "OR", "prefix_length" : 0, "max_expansions" : 50, "fuzzy_transpositions" : true, "lenient" : false, "zero_terms_query" : "NONE", "auto_generate_synonyms_phrase_query" : true, "boost" : 2.0 } } }, .
.........................
}\ }","index_uuid":"fMJ-vmT5Qu2_9PX3yJvMsw","index":"digi_live_product_1_v6","caused_by":{"type":"number_format_exception","reason":"For input string: \"sams sams\""}}}]},"status":400} at
vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php:632)"} []

I have tried every possible way like restart elastic search and reindex Magento but not working.
Magento version: 2.4.2
Elasticsearch version: 7.6

Any help is much appreciated!!

Was it helpful?

Solution

By the looks of it, you have some numerical (int or decimal) attribute which is set to be searchable and causes the error as it would expect a number to be provided.

You can:

  1. Check all your searchable attributes and make those which have a numerical data type to be set as not searchable.
  2. If you want to keep the attribute as searchable, then enable coerce on those fields in ES document mapping.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top