On Monday 24 February 2003 04:39, none none wrote: > hi, > i saw some changes on the MultiTermQuery, it is abstract and there is no > getQuery() anymore. How do i get all the terms from all the classes that > extends MultiTermQuery ?? Anybody can help me? i am moving my software to > latest version, currently is 1.2 in my application. thank you.
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. :-) -+ Tatu +- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
