为什么lucene.net荧光笔只突出第一次出现

时间:2015-10-24 02:24:34

标签: lucene lucene.net

我有这个代码。为什么只突出显示第一次出现?

this

我将此方法称为

  public string SearchY(string htmlContent, string searchText)
        {
               ISet<String> stopWords = getUpdatedStandardAnalyserStopWords(System.Environment.CurrentDirectory + "\\stopwords.txt");
               try
               {
                   using (StandardAnalyzer standardAnalyzer = new StandardAnalyzer(Version.LUCENE_30, stopWords))
                   {
                       QueryParser parser = new QueryParser(Version.LUCENE_30, "Content", standardAnalyzer);
                       Query query = parser.Parse(searchText);
                       QueryScorer scorer = new QueryScorer(query, "Content");
                       SimpleHTMLFormatter htmlFormatter = new SimpleHTMLFormatter("<span style=\"font-weight:bold; background-color:yellow;\">", "</span>");
                       Highlighter highlighter = new Highlighter(htmlFormatter, scorer);
                       highlighter.TextFragmenter = new NullFragmenter();
                       StandardTokenizer tonizer = new StandardTokenizer(Version.LUCENE_30, new IO.StringReader(searchText));
                      string m2 = highlighter.GetBestFragments(tonizer, htmlContent, 1000, "...");                        
                       return m2;



                   }
               }
               catch (Exception ex)
               {
                   string exMesg = ex.Message;
                   return exMesg;
               }

        }

这就是我所得到的。

string d = SearchY("abc sded abc sedff abe abc sss","abc");

为什么不突出显示&#34; abc&#34;?

的其他事件

0 个答案:

没有答案