Skip to main content

Magento 2 search results relevance with elasticsearch?

Magento 2.3 still use "OR" logic for mysql and elasticsearch. Plus "should" conditions (query to ES) are wrong. That's why relevance almost same. But ES significantly improve performance of search and catalog (layered navigation).

 

you have to set AND operator in your elastic search json queries, Override the module-elasticsearch/SearchAdapter/Query/Builder/Match.php. file in your custom module and then The code you have to edit in the build function in line no 75

 

if($matchKey != 'match_phrase_prefix'){$matchQuery['operator'] = "AND";} 

 

Also make sure you are not setting the operator in match_phrase_prefix.

After this you'll get exact matches in catalog search.

 

reference : https://www.generacodice.com/en/articolo/2989285/magento-2.3-search-results-relevance-with-elasticsearch&amp%3Bquest%3B