Could anyone give an example of how to use the MoreLikeThis feature in Lucene.NET. I have searched online and cannot find a single example.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
(Resurrecting an old question!)
As an example for Lucene.Net 2.9.4g:
var moreLikeThis = new Lucene.Net.Search.Similar.MoreLikeThis(indexReader);
moreLikeThis.SetAnalyzer(analyzer);
moreLikeThis.SetFieldNames(fieldNames);
moreLikeThis.SetStopWords(stopWords);
moreLikeThis.SetMinWordLen(2);
var query = moreLikeThis.Like(new System.IO.StringReader(similarity));
This generates a Lucene.Net.Search.Query object that can be used to search for documents that are similar to the text passed into the StringReader object.