我试图将这个 MoreLikeThis 示例“升级”到 Lucene 5.2.1。我能够让它运行,但我不明白fieldName
方法参数的目的like(String fieldName, Reader... readers)
。
文档的创建和索引为
Document doc = new Document();
doc.add(new StringField("id", id, Store.YES));
doc.add(new Field("title", title, type));
doc.add(new Field("content", content, type));
查询初始化如下
MoreLikeThis mlt = new MoreLikeThis(reader);
mlt.setFieldNames(new String[] { "title", "content" });
Reader sReader = new StringReader(searchForSimilar);
Query query = mlt.like("title", sReader);
正如我所说,它按预期工作。类似的文档被适当地恢复和排名。所以,由于de API没有解释参数,我做了一些实验:代替“title”,我将它改为“content”,“xxx”和NULL。
他们都返回了相同的文件,分数相同......
我试图在 Lucene 源码里面查看,参数是用来调用addTermFrequencies
的,然后是analyzer.tokenStream(fieldName, r)
. 之后,据我所知,代码变得复杂......
所以,这个论点似乎是“重要的”,但正如我所说,它没有任何区别。
有谁知道它的目的?