如何在 Lucene 中找到给定文档的相似文档。我不知道文本是什么,我只知道文档是什么。有没有办法在lucene中找到类似的文档。我是新手,所以我可能需要一些指导。
你可能想检查 lucene 的 MoreLikeThis 功能。
MoreLikeThis 根据文档中的术语构建 lucene 查询,以查找索引中的其他相似文档。
http://lucene.apache.org/java/3_0_1/api/contrib-queries/org/apache/lucene/search/similar/MoreLikeThis.html http://lucene.apache.org/java/3_0_1/api/contrib-queries/org/apache/lucene/search/similar/MoreLikeThis.html
示例代码示例(java 参考)-
MoreLikeThis mlt = new MoreLikeThis(reader); // Pass the index reader
mlt.setFieldNames(new String[] {"title", "author"}); // specify the fields for similiarity
Query query = mlt.like(docID); // Pass the doc id
TopDocs similarDocs = searcher.search(query, 10); // Use the searcher
if (similarDocs.totalHits == 0)
// Do handling
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)