lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@lucene.com>
Subject Re: MultiTermQuery question
Date Mon, 24 Feb 2003 16:51:22 GMT
Tatu Saloranta wrote:
> It would be nice if all queries would have a method that allows terms to be 
> collected, ie. so that Query base class would have an abstract method.
> Visitor pattern might make most sense; so we could have a TermCollector 
> object, and queries could have method like:
> 
> void collectTerms(TermCollector c)
> 
> which would do something like
> 
> c.collectTerm(t, this);
> 
> for each term it contains, and/or
> 
> q.collectTerms(c)
> 
> for each sub-query it contains, to get terms recursively.
> 
> Then, TermCollector would need to define 'collectTerm(Term t, Query q);' to
> collect all terms, and have method(s) for getting all terms plus resetting it 
> (if it's to be reused). Some TermCollectors could also keep track of queries 
> terms came from, to allow keeping track of phrase query term dependencies 
> etc. etc.
> Using visitor would be more elegant than having to check class types and casts 
> when traversing. Plus, when adding new queries, would only need to add that 
> one method, and visitors would still work ok.
> 
> ... having described this, I probably should just go and implement it I guess. 

+1


---------------------------------------------------------------------
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