Solr: combining EdgeNGramFilterFactory and NGramFilterFactory

前端 未结 2 792
我在风中等你
我在风中等你 2021-02-09 13:59

I have a situation where I need to use both EdgeNGramFilterFactory and NGramFilterFactory.

I am using NGramFilterFactory to perform a \"contains\" style search with min

2条回答
  •  不思量自难忘°
    2021-02-09 14:34

    You don't necessarily have to do all this in the same field. I would create a different fields using different custom types for each treatment so that you can apply the logic separately.

    In the following:

    • text contains the original tokens, minimally processed;
    • text_ngram uses the NGramFilter for your two-character-minimum tokens
    • text_first_letter uses EdgeNGram for your one-character initial-letter tokens

    If you're processing all text fields in this way, then you might be able to get away with using a copyField to populate the fields. Otherwise, you can instruct your Solr client to send in the same field values for the three separate field types.

    When searching, include all of them in your searches with the qf parameter.

    
      
        
        
        
      
    
    
    
      
        
        
        
        
      
    
    
    
      
        
        
        
        
      
    
    

    Setting up field and dynamicField definitions are left up to you. Or let me know if you have more questions and I can edit with clarifications.

提交回复
热议问题