2

I have a Magento 2 site with product titles and descriptions in Portuguese, that uses Elasticsearch as the catalog search engine. When I search for terms with accents the search results quality is very poor. Taking a stab at the issue I found out that magento creates the indices with an english stemmer, which is not appropriate for my case, as seen in the following image:

enter image description here

I know I can change the stemmer to be in portuguese, via direct manipulation on elasticsearch, but upon each magento indexer:reindex the old indice is deleted and a new one is created again with english, so that would not be a feasible solution.

Further digging into the issue I found that there's an esconfig.xml in the Magento_Elasticsearch module which is base to Magento_Elasticsearch6, with the following structure

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Elasticsearch:etc/esconfig.xsd">
    <stemmer>
        <type>stemmer</type>
        <default>english</default>
        <de_DE>german</de_DE>
        <en_US>english</en_US>
        <es_ES>spanish</es_ES>
        <fr_FR>french</fr_FR>
        <nl_NL>dutch</nl_NL>
        <pt_BR>portuguese</pt_BR>
    </stemmer>
    <stopwords_file>
        <default>stopwords.csv</default>
        <de_DE>stopwords_de_DE.csv</de_DE>
        <en_US>stopwords_en_US.csv</en_US>
        <es_ES>stopwords_es_ES.csv</es_ES>
        <fr_FR>stopwords_fr_FR.csv</fr_FR>
        <nl_NL>stopwords_nl_NL.csv</nl_NL>
        <pt_BR>stopwords_pt_BR.csv</pt_BR>
    </stopwords_file>
</config>

I wonder what is the proper way to override this file as to make Magento use a portuguese stemmer by default?

Thanks

1 Answer 1

0

I think No need to override any file.

Try below with the default system configuration, Magento does provides such a setting.

Stemmer works on the value configured on the store level.

  1. On the Admin sidebar, go to Stores > Settings > Configuration and switch to the specific store view if the website has multiple store views.
  2. In the left panel under General, choose General.
  3. Expand Expansion selector the Locale Options section
  4. unchecked Use Website if exists and Set Locale to the store language to Portuguese (Brazil) or Portuguese (Portugal) as per your convenience.
  5. Save config and clear cache if needed.

Run the catalog search index command - php bin/magento indexer:reindex catalogsearch_fulltext

For more info, https://docs.magento.com/m2/ce/user_guide/stores/locale-options.html#to-set-the-store-locale

2
  • After doing this the stemmer still remains as english. Mar 14, 2020 at 13:13
  • It should work unless some custom module changes.
    – sandip
    Mar 14, 2020 at 22:07

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.