What is the correct way to change an indice's stemmer on Elasticsearch when using magento

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"

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



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

Similar questions

Is this a correct way change theme programatically via "layout_load_before" event Observer?
In need to change themes based on customer group. after some google I found a hook where I can made a change "layout_load_before". I am not sure this is effective solution or not. I mean here. Does this will affect theme fallback system of magento2? Does this effect to full page cache system of magento2? All I need proper explanation of doing this....
Correct way to change core module code
I have one line of code in a core module (contact) in which I need to change. What is the correct way to make the change to change/overwrite this file?
Elasticsearch: Does search in frontend work that way?
I thought my Elasticsearch is configured correctly. 'Test connection' in the admin panel is successful and the quick search there shows many entries as dropdown, as you can see in the screenshot below. I have already reindexed - if this is all what is required to build up data in Elasticsearch. But I have two problems: If I enter something into the...
is it correct to change all magento folders permission to 755 and all files to 644 using chmod?
is it correct if i change all files permisson to 644 and all folders to 755 using following commands?
What is the correct way to update a value to be NULL on a Magento model?
I am having an issue getting a custom model's value to update to NULL. This code does not update the field custom_value in the database, and the database value accepts NULL values (Manually setting NULL in the database works fine). EDIT: As Tim mentions below using Zend_Db_Expr("NULL") does set the value to null, could anyone explain why this is re...
magento 1.9 correct way to extend Mage_Adminhtml_Catalog_ProductController
y'all. What is the best way to achieve this epic feat of intellectual prowess? Is this a good start? From that point, what else must be achieved?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.