1
votes

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.

1
Hmm...seems I know too little of lucene for what I'm trying. I had a boost factor on 1 query of Float.MAX_VALUE...because an exact hit on that was above all other. Reducing this to, say 10, makes scoring re-appear. Can anyone perhaps explain why this is ? (and it still puzzles me that Luke made the search just fine with the high boost)user966217

1 Answers

1
votes

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.