lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Labrot <>
Subject BooleanQuery question
Date Wed, 19 Jul 2006 15:59:51 GMT

I have made a simple class that parse an XML boolean expression to 
create predefined query .

Here is an unroll construction from an xml topic which reduce the search 
on path "/bssrs" and exclude the file "abstract.htm" :

        subsubTermQuery1 = new TermQuery(new Term("FILE", "abstract.htm"));
        subsubBoolQuery1.add( new BooleanClause(subsubTermQuery1 , 
BooleanClause.Occur.SHOULD) );
    subBoolQuery1.add( new BooleanClause(subsubBoolQuery1, 
BooleanClause.Occur.MUST_NOT) );

    subTermQuery2 = new TermQuery(new Term("PATH", "/bssrs"));
    subBoolQuery2.add( new BooleanClause(subTermQuery2 , 
BooleanClause.Occur.SHOULD) );

boolQuery.add( new BooleanClause(subBoolQuery1, BooleanClause.Occur.MUST) );
boolQuery.add( new BooleanClause(subBoolQuery2, 
BooleanClause.Occur.MUST) );

That give me after boolQuery.toString() this expression :
+(-(FILE:abstract.htm)) +(PATH:/bssrs)

If  I search with boolQuery, Lucene doesn't find anything.
If I modify by hand the query from "+(-(FILE:abstract.htm)) 
+(PATH:/bssrs)" to "-(FILE:abstract.htm) +(PATH:/bssrs)", Lucene find 
the correct list of document.

Does somebody know why ?

Thanks in advance,


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message