java - Lucene 的评分如何取决于查询的相对位置?

标签 java search lucene

我使用 WhitespaceAnalyzer 作为查询分析器。 如果我有 2 个文档:

| text | a b c |
| text | b a c |

text 是一个字段。

现在索引结构是这样的:

|Term|  in document | 
| a  | a b c / b a c|
| b  | a b c / b a c|
| c  | a b c / b a c|

我有一个疑问:

| text | a b c |

如何才能获得较高的 a b c 分数和较低的 b a c 分数。

Lucene是否支持根据相对位置计算分数?

我发现这会有所帮助:

PhraseQuery phraseQuery = new PhraseQuery();
phraseQuery.setSlop(1);

这样他们就会得到不同的分数。

查看更多:http://www.blogjava.net/tangzurui/archive/2008/09/22/230357.html

在这里我遇到了另一个问题: https://stackoverflow.com/questions/18394532/how-can-lucenes-scoring-depend-on-terms-relative-position-in-the-document

最佳答案

这取决于您使用的查询类型。如果您搜索的短语按正确顺序放置(例如 new york 或 york new),某些查询可能会获得更高的分数。根据 Lucene 文档,您可以使用分数解释来查看为什么 A B C 的分数高于 B A C。

Scoring is very much dependent on the way documents are indexed, so it is important to understand indexing (see Apache Lucene - Getting Started Guide and the Lucene file formats before continuing on with this section.) It is also assumed that readers know how to use the Searcher.explain(Query query, int doc) functionality, which can go a long way in informing why a score is returned.

http://lucene.apache.org/core/3_6_2/scoring.html

UPD。如果您使用 Lucene 3,要存储术语的位置,请查看此内容 http://lucene.apache.org/core/3_0_3/api/core/org/apache/lucene/document/Field.TermVector.html

关于java - Lucene 的评分如何取决于查询的相对位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18247778/

相关文章:

java.lang.StackOverflowError ManyToMany : MapStruct - Spring Boot - Hibernate

search - 计算lucene索引中的词频

arrays - 慢速 CPU 的快速索引?

python - 尝试为 python 安装 lucene。首先需要安装jcc。为 jcc 构建 setup.py 时,出现错误 ld : library not found for -ljava

java - android & Java 中的外来字符

java - java 向上舍入到小数点后两位,而不重新分配给新变量

Lucene 4.4.0 新增 ControlledRealTimeReopenThread 示例用法

java - 如果排序字段为 "",lucene 如何使用比较器处理排序字段

java - 将 xyz 数据转换为可由站点访问者旋转和缩放的 3D 图像

c# - 最快从搜索算法开始