Lucene文档分数在搜索后似乎丢失
在 lucene 3.1 中,我有一个大型布尔查询,我像这样执行:
IndexSearcher is = new IndexSearcher(myDir); is.search(查询, 10);
我得到了 10 个结果,但它们是按 docId 排序的,并且不包含分数信息。我能找到的所有文档都说 lucene 默认情况下按相关性/分数排序,但对我来说情况并非如此。如果我要求解释,没有分数信息,只有“0.0”。有趣的是,如果我在 Luke 中对同一索引执行相同的查询,我会得到按分数排序的结果,但我看不到如何让分数保留并在从应用程序启动时用于排序。所以我相信这个查询很好,看看它在 Luke 中是如何工作的。
我做错了什么?我也尝试过设置 is.setDefaultFielsSortScoring(true,true) 但这没有什么区别。我尝试使用 TopScoreDocColletor 但没有成功。
In lucene 3.1 i have a large boolean query, that i execute like so:
IndexSearcher is = new IndexSearcher(myDir);
is.search(query, 10);
I get 10 results just fine, but they are sorted by docId, and contain no score information. All documentation i can find, says that lucene by default sorts by relevance/score but this is not the case for me. If I ask for explain, there is no score information, just "0.0". Funny thing is that if I execute the same query in Luke on the same index, i get a result sorted by score just fine, but I can't see how to get the scores to stay and be used for sorting when launched from app. So I believe the query is just fine, seeing how it works in Luke.
What am I doing wrong ? I have also tried setting is.setDefaultFielsSortScoring(true,true) but this makes no difference. I tried using TopScoreDocColletor with no success.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 Lucene 评分,特别是查询范数。如果您的权重之一是
Float.MAX_VALUE
,则其他所有值都将足够接近零,以至于小于机器精度。Look at Lucene scoring, particularly the query norm. If one of your weights is
Float.MAX_VALUE
everything else will be close enough to zero that it's smaller than machine precision.