That's right. I just had another decorator which was not adapted for the new API. My fault ..
Thanks, Jerome. 2009/8/18 Mark Miller <markrmil...@gmail.com>: > I'm pretty sure one of them is called. In the version you have: > > public void search(Query query, HitCollector results) > throws IOException { > search(createQueryWeight(query), null, new HitCollectorWrapper(results)); > } > > protected QueryWeight createQueryWeight(Query query) throws IOException { > return query.queryWeight(this); > } > > > Query.queryWeight will in turn call Query.createQueryWight (either for your > Query, or for the primitive Query > it rewrites itself too). > > > > -- > - Mark > > http://www.lucidimagination.com > > > > Jérôme Etévé wrote: >> >> Hi Mark, >> >> >> Thanks for clarifying this. So should I keep both sets of method >> implemented? I guess it won't hurt when solr trunk will use the >> updated version of lucene without those methods. >> >> What I don't get is that neither my createWeight or createQueryWeight >> methods seem to be called when I call >> rb.req.getSearcher().search(limitedQuery, myCollector); >> >> I'll look at the code to find out. >> >> Thanks! >> >> Jerome >> >> 2009/8/18 Mark Miller <markrmil...@gmail.com>: >> >>> >>> You have run into some stuff that has been somewhat rolled back in >>> Lucene. >>> >>> QueryWieght, and the methods it brought have been reverted. >>> >>> Shortly (when Solr trunk updates Lucene), Solr will go back to just >>> createWeight and weight. >>> >>> The main change that will be left is that Weight will be an abstract >>> class >>> rather than an interface. >>> >>> >>> -- >>> - Mark >>> >>> http://www.lucidimagination.com >>> >>> Jérôme Etévé wrote: >>> >>>> >>>> Hi all, >>>> >>>> I have a custom search component which uses a query I wrote. >>>> Basically, this Query (called DocSetQuery) is a Query decorator that >>>> skips any document which is not in a given document set. My code used >>>> to work perfectly in solr 1.3 but in solr 1.4, it seems that my >>>> DocSetQuery has lost all its power. >>>> >>>> I noticed that to be compliant with solr 1.4 trunk and the lucene it >>>> contains, I should implement two new methods: >>>> >>>> createQueryWeight >>>> and >>>> queryWeight >>>> >>>> So I did. It was very easy, because basically it's only about re-using >>>> the deprecated Weight createWeight and wrapping the result with a >>>> QueryWeightWrapper. >>>> >>>> So now I believe my DocSetQuery complies with the new >>>> solr1.4/lucene2.9-dev api. And I've got those methods: >>>> >>>> public QueryWeight queryWeight(Searcher searcher) throws IOException { >>>> return createQueryWeight(searcher); >>>> } >>>> public QueryWeight createQueryWeight(Searcher searcher) throws >>>> IOException >>>> { >>>> log.info("[sponsoring] creating QueryWeight calling createQueryWeight >>>> "); >>>> return new QueryWeightWrapper(createWeight(searcher)); >>>> } >>>> public Weight weight(Searcher searcher) throws IOException { >>>> return createWeight(searcher); >>>> } >>>> >>>> //and of course >>>> >>>> protected Weight createWeight(final Searcher searcher) throws >>>> IOException >>>> { >>>> log.info("[sponsoring] creating weight with DoCset " + docset.size()); >>>> ... >>>> } >>>> >>>> I'm then using my DocSetQuery in my custom SearchComponent like that: >>>> >>>> Query limitedQuery = new DocSetQuery(decoratedQuery , ... ); >>>> >>>> Then I simply perform a search by doing >>>> >>>> rb.req.getSearcher().search(limitedQuery, myCollector); >>>> >>>> My problem is neither of createQueryWeight or createWeight is called >>>> by the solr Searcher, and I'm wondering what I did wrong. >>>> Should I build the Weight myself and call the search method which >>>> accepts a Weight object? >>>> >>>> This is quite confusing because: >>>> - it used to work perfectly in solr 1.3 >>>> - in the nightly build version of lucene API, those new methods >>>> createQueryWeight and queryWeight have disappeared but with the lucene >>>> solr1.4trunk uses, they exists plus the old ones ( createWeight and >>>> weight) are deprecated. >>>> >>>> >>>> Thanks for your help. >>>> >>>> Jerome Eteve. >>>> >>>> >>> >>> >>> >>> >> >> >> >> > > > > > -- Jerome Eteve. Chat with me live at http://www.eteve.net jer...@eteve.net