lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re: sub-scores for all clauses in a BooleanQuery
Date Tue, 28 Apr 2009 23:11:06 GMT

: I've also tried getting the scores by walking the clauses of the
: BooleanQuery, but that doesn't seem to work either, because the
: queryNorm is off. For example, here's an original explanation for a
: 3-clause query, where one clause doesn't match:

a simple solution would be to eliminate the queryNorm completely (you can 
override it in your Similarity class) ... depending on your use case you 
might not need it at all.

: So how can I get the correct sub-scores for *all* clauses of a
: BooleanQuery, regardless of whether they matched or not?

well, first off: if a clause didn't match, then by definition there is no 
score to get from that clause ... but i'm guessing what you ment to say is 
how do you get the sub-scores from all of the clauses that *did* match, 
and know which clauses *didn't* match.

i haven't tried this, but i think something like this would work...

Weight tmp = yourBooleanQuery.weight(yourSearcher);
float norm = yourSearcher.getSimilarity().queryNorm(tmp.sumOfSquaredWeights());
for (BooleanClause c : yourBooleanQuery.getClauses()) {
   Weight w = c.getQuery().weight(yourSearcher);
   doSomethingWithExplain(w.explain(yourReader, yourDocId));


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message