Question

Having custom module dependency injection as follows:

  1. di.xml in app/code/Custom/Stopwords/etc directory.

    <type name="Magento\Elasticsearch\SearchAdapter\Query\Preprocessor\Stopwords">
     <arguments>
         <argument name="stopwordsDirectory" xsi:type="string">app/code/Custom/Stopwords/etc/stopwords</argument>
     </arguments>
    

  2. stopwords_en_US.csv in app/code/Custom/Stopwords/etc/stopwords directory copied from vendor.

Dev docs guide which i'm referring

Edit

I would like to add few stopwords in the .csv file. Have added the stop-words as follows:

more less some few other misc all

Issue - after adding the above stop-words it is not getting applied.

Was it helpful?

Solution

I ran into the same issue that you had following the documentation provided. You were following the Change Stopword Directory instead you want to follow the instructions under To change the directory from your module

In you custom module etc/di.xml file add in the following

<type name="Magento\Elasticsearch\SearchAdapter\Query\Preprocessor\Stopwords">
<arguments>
   <argument name="stopwordsModule" xsi:type="string">Your_Module</argument>
   <argument name="stopwordsDirectory" xsi:type="string">stopwords</argument>
</arguments>

Then make sure to copy vendor\magento\module-elasticsearch\etc\stopwords\stopwords.csv to app/code/Your/Module/etc/stopwords/stopwords.csv and add your words at the end of the file adding a new line for each word.

Once you are done I recommend rebuilding the indexes.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top