You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Nellai <ng...@eforceglobal.com> on 2003/02/11 15:48:20 UTC
% of Relevance
Hi!
can anyone tell me how to calculate the % of relevance using Lucene.
Thanks in advance
Nellai...
Re: % of Relevance
Posted by Tatu Saloranta <ta...@hypermall.net>.
On Tuesday 11 February 2003 07:48, Nellai wrote:
> Hi!
>
> can anyone tell me how to calculate the % of relevance using Lucene.
Lucene's hit score is normalized float, ] 0.0, 1.0 ] (since 0.0 ones are never
included). From there it's basic arithmetics (perhaps this could be included
in FAQ , even though it is fairly trivial). The simples way would be:
... // get the search results,
float score = hits.score(docNr); // between 0.0 and 1.0 (including 1.0)
int pctScore = (int) (100.0f * score);
Also note that it's not guaranteed that all searches have any 100% matching
docs; for example when none of the docs matches all clauses, and clauses are
combined with OR-query. Same may also happen (I think?) if best match for
different sub-clauses is different?
You may also want to normalize the score if you always want your top match to
be 100% (or have some range that gets rounded up)... users are known to want
silly features like that. :-)
-+ Tatu +-
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org