Lucene的评分如何取决于查询的相对位置? [英] How can Lucene's scoring depend on relative position of query?
问题描述
我使用WhitespaceAnalyzer
作为查询分析器.
如果我有2个文档:
I use WhitespaceAnalyzer
as query analyzer.
If I have 2 documents:
| text | a b c |
| text | b a c |
text
是一个字段.
现在索引结构是这样的:
Now the index structure is something like this:
|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
获得更低的分数.
How can I get a higher score for a b c
and a lower one for b a c
.
Lucene是否支持根据相对位置来计算分数?
Does Lucene support calculating score depending on relative position?
我发现这会有所帮助:
PhraseQuery phraseQuery = new PhraseQuery();
phraseQuery.setSlop(1);
这样,他们将获得不同的分数.
In this way they would get different scores.
查看更多信息: http://www.blogjava. net/tangzurui/archive/2008/09/22/230357.html
And here I come across another question:
> https://stackoverflow.com/Questions/18394532/Lucenes如何根据字词在文档中的相对位置进行评分
推荐答案
短语匹配的得分贡献取决于距离:
The score contribution of a phrase match depends on the distance:
- 距离最高分= 0(完全匹配).
- 距离越远,得分就越低.
对于您的案例,查询"a b c"将与文档"a b c"匹配,且距离为0.这将导致短语得分最高.对于文档"b a c",距离将大于0.因此,得分将减小.
For your case query "a b c" will match with document "a b c" with distance 0. This will result to highest phrase score. For document "b a c" distance will be more than 0. So Score will be less.
有关更多详细信息,请参见 org.apache.lucene.search.SloppyPhraseScorer 类的源代码.
For more details look at source code of org.apache.lucene.search.SloppyPhraseScorer Class.
这篇关于Lucene的评分如何取决于查询的相对位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!