Is there way to boost original term more while using Solr synonyms?

前端 未结 1 1892
北恋
北恋 2021-02-05 22:20

For example I have synonyms laptop,netbook,notebook in index_synonyms.txt

When user search for netbook I want to boost original text more then expanded by synonyms? Is

1条回答
  •  故里飘歌
    2021-02-05 22:48

    As far as I know, there is no way to do this with the existing SynonymFilterFactory. But following is a trick you can use to get this behavior.

    Let's say your field is called title. Create another field which is a copy of this, say title_synonyms. Now ensure that SynonymFilterFactory is used as an analyzer only for title_synonyms (you can do this by using different field types for the two fields — say text and text_synonyms). Search in both these fields but give higher boost to title than title_synonyms.

    Here are sample field type definitions:

        
            
                
                
                
                
            
            
                
                
                
                
            
        
    
        
            
                
                
                
                
                
            
            
                
                
                
                
                
            
        
    

    And here are sample field definitions:

        
        
    

    Copy title field to title_synonyms:

    
    

    If you are using dismax, you can give different boosts to these fields like so:

        title^10 title_synonyms^1
    

    0 讨论(0)
提交回复
热议问题