lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Miller <markrmil...@gmail.com>
Subject Re: Writing and using your own Query class in solr 1.4 (trunk)
Date Tue, 18 Aug 2009 12:19:14 GMT
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.
>





Mime
View raw message