Lucene.NET MoreLikeThis Example

纵然是瞬间 提交于 2019-12-06 11:41:58

问题


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.



来源:https://stackoverflow.com/questions/7494346/lucene-net-morelikethis-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!