Lucene.NET MoreLikeThis Example

2019-04-13 01:36发布

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条回答
唯我独甜
2楼-- · 2019-04-13 02:40

(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.

查看更多
登录 后发表回答