开发者

Lucene document score appears to be lost after search

开发者 https://www.devze.com 2023-04-08 10:00 出处:网络
In lucene 3.1 i have a large boolean query, that i execute like so: IndexSearcher is = new IndexSearcher(myDir);

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开发者_如何学JAVA 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号