我选择了一些包含特定单词的行,例如 StackOverFlow
从我的数据库中并将它们保存在文本文件中。
然后,我使用 Lucene 来索引文件内容。
当我尝试搜索StackOverFlow
时在使用 Carrot2 的索引文件上,它不返回任何文档,但换句话说,我知道它们至少存在于一个文档中,它会返回其中的一些文档。
在Carrot2文档中,有一个关于 Maximum word document frequency
属性的解释:
Maximum word document frequency. The maximum document frequency allowed for words as a fraction of all documents. Words with document frequency larger than maxWordDf will be ignored. For example, when maxWordDf is 0.4, words appearing in more than 40% of documents will be be ignored. A value of 1.0 means that all words will be taken into account, no matter in how many documents they appear. This attribute may be useful when certain words appear in most of the input documents (e.g. company name from header or footer) and such words dominate the cluster labels. In such case, setting maxWordDf to a value lower than 1.0, e.g. 0.9 may improve the clusters.
Another useful application of this attribute is when there is a need to generate only very specific clusters, i.e. clusters containing small numbers of documents. This can be achieved by setting maxWordDf to extremely low values, e.g. 0.1 or 0.05.
所以,当我设置maxWordDf
时到 1.0,没有任何变化,并且在搜索中仍然不显示任何文档。
如何解决我的问题?
最佳答案
搜索结果中文档缺失的原因通常是用于索引文档的分析器与 Carrot2 在搜索过程中使用的分析器不匹配。默认情况下,Carrot2 使用 Lucene 的 StandardAnalyzer
,您可以使用 LuceneDocumentSource.analyzer 提供不同的分析器。属性。
关于java - Carrot2 在搜索时不显示所有包含特定单词的簇,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49095981/