lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wolf Siberski <siber...@l3s.de>
Subject Re: How to proceed with Bug 31841 - MultiSearcher problems with Similarity.docFreq() ?
Date Tue, 22 Feb 2005 15:40:38 GMT
Doug Cutting wrote:
> Wolf Siberski wrote:
> 
>> Now I found another solution which requires more changes, but IMHO is
>> much cleaner:
>> - when a query computes its Weight, it caches it in an attribute
>> - a query can be 'frozen'. A frozen query always returns the cached
>>   Weight when calling Query.weight().
> 
> 
> Orignally there was no Weight in Lucene, only Query and Scorer.  Weight 
> was added in order to make it so that searching did not modify a Query, 
> so that a Query instance could be reused.  Searcher-dependent state of 
> the query is meant to reside in the Weight.  IndexReader dependent state 
> resides in the Scorer.  Your "freezing" a query violates this.  Can't we 
> create the weight once in Searcher.search?
> 
I see. Yes, it is possible to avoid this by sending the weights to the Searchables
instead of the queries. This is much better, because it becomes more explicit
what is going on. The price is an extension (or modification) of the
Searchable interface. I've added corresponding search(Weight...) methods
to the existing search(Query...) methods and deprecated the latter.
If Searchable is meant to be Lucene internal, then IMHO these 'duplicates'
should be removed.

Regarding your other comments: I've been a bit too eager in refactoring,
not giving enough thought to backward compatibility issues. Now I've
reverted to existing API and behavior as far as (IMHO) possible,
and that was pretty far. The only API change necessary is
createWeight() _throws IOException_, because the idfs have to
be computed in the Weight constructors.

Thanks for your valuable feedback. It helped a lot to understand
the Lucene 'spirit' behind the code. An improved patch is attached
to the Bugzilla issue.

--Wolf

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Mime
View raw message