Changing the default operator from OR to AND in Solr (Magento Enterprise)

前端 未结 6 1319
一向
一向 2021-02-01 23:28

I\'m using Solr with Magento Enterprise. I\'m trying to change the default search operator from OR to AND to make searches more specific by default.

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-02 00:09

    Thanks to Macilias' link on the dismax parser plugin I've found a way to accomplish this with the settings in the solrconfig.xml. In this file there are requestHandler nodes for a bunch of different languages. I modified the english one since our store is in english. By default the xml looked like this:

    
        
            fulltext_1_en^1.0 fulltext_2_en^2.0 fulltext_3_en^3.0 fulltext_4_en^4.0 fulltext_5_en^5.0
            fulltext_1_en^1.0 fulltext_2_en^2.0 fulltext_3_en^3.0 fulltext_4_en^4.0 fulltext_5_en^5.0
            1
            1
            dismax
            explicit
            false
            false
            1
        
        
            spellcheck
        
    
    

    The important parameter here is "mm" which stands for Minimum 'Should' Match. The dismax parser uses this instead of a default operator to determine how multiple search terms should be handled. A value of 1 means only one term from the query must match (same behavior as OR). A value of 100% mean all the terms must match (same behavior as AND). More complex values can be used as well. Follow the link above for more info. After changing settings in the solrconfig.xml file you'll need to restart the Solr server before they take effect.

    This video is also a good Magento Solr resource: http://www.youtube.com/watch?v=07uIJSXdqpU They talk about Minimum Match around the 24 minute mark.

提交回复
热议问题