Different analyzers for each field

后端 未结 3 1114
失恋的感觉
失恋的感觉 2021-02-05 05:29

How can I enable different analyzers for each field in a document I\'m indexing with Lucene? Example:

        RAMDirectory dir = new RAMDirectory();
        Ind         


        
3条回答
  •  深忆病人
    2021-02-05 06:10

    Map analyzerMap = new HashMap();
    analyzerMap.put(fieldone, new IKAnalyzer4PinYin(false, IKAnalyzer4PinYin.PINYIN));
    analyzerMap.put(fieldtwo, new IKAnalyzer4PinYin(false, KAnalyzer4PinYin.PINYIN_SHOUZIMU));
    PerFieldAnalyzerWrapper wrapper = new PerFieldAnalyzerWrapper(new IKAnalyzer4PinYin(false), analyzerMap);
    
    IndexWriterConfig iwConfig = new IndexWriterConfig(Version.LUCENE_40 , wrapper);
    

提交回复
热议问题