lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doron Cohen <DOR...@il.ibm.com>
Subject Re: Filter query method
Date Wed, 08 Nov 2006 07:16:18 GMT
Hi Wooi Meng,

I don't understand this code.
In particular, searchString1 has no efect, and not clear what are start and
end.

spinergywmy <spinergywmy@gmail.com> wrote on 07/11/2006 17:04:45:
> Query query1 = parser.parse(searchString1);
> Query query2 = parser.parse(searchString2);
>
> filter = new Filter(){
>   public BitSet bits (IndexReader reader){
>     BitSet bits = new BitSet(reader.maxDoc());
>     for(int i=start; (i<end && i<bits.size()); i++)
>       bits.set(i);
>     return bits;
>   }
> };
>
> BooleanQuery bq = new BooleanQuery();
> query1 = new FilteredQuery(new MatchAllDocQuery(), filter);
> bq.add(query1, BooleanClause.Occur.MUST);
> bq.add(query2, BooleanClause.Occur.MUST);
>
> searchHits = searcher.search(bq);

Anyhow, if you do not cache the results of the first search, two simple
options are:

(1) score by both str1 and str2:

    Query query1 = parser.parse(searchString1);
    Query query2 = parser.parse(searchString2);
    BooleanQuery q = new BooleanQuery();
    q.add(query1, BooleanClause.Occur.MUST);
    q.add(query2, BooleanClause.Occur.MUST);
    Hits searchHits = searcher.search(q);

(2) score ony by str, filter by str1:

    Query query1 = parser.parse(searchString1);
    Filter f1 = new QueryFilter(query1);
    Query q2 = parser.parse(searchString2);
    Hits searchHits = searcher.search(q2,f1);

I would start with this, and go for caching only if performance issues
justify that.

Doron


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


Mime
View raw message