1
我想添加Lucene.NET熒光筆到我的搜索,但它做了一些真奇怪的突出顯示,我做錯了什麼?lucene.NET熒光筆插件突出顯示奇怪
繼承人的高亮代碼:
// stuff here to get scoreDocs
var content = doc.GetField("content").StringValue();
// content = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been"
var highlighter = new Highlighter(new StrongFormatter(), new HtmlEncoder(), new QueryScorer(query.Rewrite(indexSearcher.GetIndexReader())));
highlighter.SetTextFragmenter(new SimpleFragmenter(100));
var tokenStream = analyzer.TokenStream("content", new StringReader(content));
var bestFragment = highlighter.GetBestFragment(tokenStream, content);
搜索"lorem"
給我這個bestFragment值:
<strong>Lorem</strong> <strong>Ipsum</strong> is <strong>simply</strong> <strong>dummy</strong> <strong>text</strong> of the <strong>printing</strong> and <strong>typesetting</strong> <strong>industry</strong>. <strong>Lorem</strong> <strong>Ipsum</strong> <strong>has</strong> <strong>been</strong>
正如你所看到的,它強調的不僅僅是"Lorem"
得多。爲什麼?
如何讓這種行爲合理?
我使用的是StandardAnalyzer
和我的查詢看起來像"content:lorem"
* 編輯:*進出口使用Lucene.NET 2.9.2
感謝
該死的,多數民衆贊成在尷尬!謝謝,這已經讓我發瘋了!如此明顯! – 2010-12-28 20:59:03