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 Ivan Brusic <iv...@brusic.com> on 2013/12/09 18:41:28 UTC

Changing similarity at query time

I am currently using document-level boosts, which really translates to
changing the norm for every field under the covers. As part of an
experiment, I want to remove the boost, but that would require either
re-indexing content or changing the scoring algorithm (similarity).

If I create my own similarity, which would be identical to the
default/TFIDF similarity but with the norm hardcoded to 1.0. The Lucene
source warns against such behavior. I am assuming this is because it
appears computeNorm is only run at index time,but shouldn't I be able to
override score() and ignore the decodeNormValue calculation?

Cheers,

Ivan

Re: Changing similarity at query time

Posted by Ivan Brusic <iv...@brusic.com>.
To answer my own question, it appears that despite the warning, using a
custom similarity only at search time appears to be working. The score()
method was the wrong code to override, I simply hardcoded the return value
of decodeNormValue to 1.0. Since this value is used for normalization, as
long as I am consistent, it should be valid.

Now onto the real testing.

Cheers,

Ivan


On Mon, Dec 9, 2013 at 9:41 AM, Ivan Brusic <iv...@brusic.com> wrote:

> I am currently using document-level boosts, which really translates to
> changing the norm for every field under the covers. As part of an
> experiment, I want to remove the boost, but that would require either
> re-indexing content or changing the scoring algorithm (similarity).
>
> If I create my own similarity, which would be identical to the
> default/TFIDF similarity but with the norm hardcoded to 1.0. The Lucene
> source warns against such behavior. I am assuming this is because it
> appears computeNorm is only run at index time,but shouldn't I be able to
> override score() and ignore the decodeNormValue calculation?
>
> Cheers,
>
> Ivan
>