I thought a bit about this when I revised the search code last year.
Before that, Similarity was global: there was only one implementation.
I could think of cases where it might make sense to have it per-query,
but that also seemed too fine-grained, so I opted to make it
per-searcher.  But perhaps it really *should* be possible to specify a
different Similarity implementation for different queries.

Here's a proposal. We add a method to Query as follows:

  public Query#getSimilarity(Searcher searcher) {
     return searcher.getSimilarity();
  }

Then change all of the Weight and Scorer code to call this in place of
Searcher#getSimilarity().  This permits one to subclass a Query class so
that it can specify it's own Similarity implementation, perhaps one that
delegates through that of the Searcher.

Comments?

Doug

Julien Nioche wrote:
Just a question :
Classes implementing MultiTermQuery (i-e WildcardQuery and FuzzyQuery) are
changed into BooleanQueries by the 'rewrite()' method before a Search. The
default coord() method of Similarity implies that the score of this BQ is
multiplied by the (ratio number of Terms found / number of terms searched).

This is fine but it could penalize the score of a document in case a Term
expands a lot. It's still possible to write your own Similarity class but
anyway the coord() method will be the same for all *Scorer objects and the
problem is that I'd like to keep the default behaviour for the "regular"
BooleanQueries.

The question is : how can I do to have 2 different ways to compute the coord
factor or to say differently how can I choose to use it or not without
having to rewrite a whole bunch of Query and Scorer objects? Would it be
useful in general? Any ideas?

Thanks

Julien





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to