0

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!!

2

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.
4
  • Thank you so much @Diana. The weight attribute is showing in the search. So I set to no in search and now everything works fine. You are the master in Magento. – Amit Saini Apr 27 at 11:36
  • you are most welcome, glad i could help! cheers! – Diana Botean Apr 27 at 11:42
  • @DianaBotean I have same issue with weight attribute i see that my weight attribute contain float value and when we enable for the search it cause the issue can you guide i want to make searchable of weight attribute. – Magento Jun 21 at 11:06
  • have you tried changing the data type? make the attribute text/ varchar for example? – Diana Botean Jun 21 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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