lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: too many boolean clauses
Date Wed, 01 Feb 2012 08:26:04 GMT
I would recommend to use TermsFilter (, possibly wrapped
by a ConstantScoreQuery). You must do the query building by hand, yuery
*parser* cannot do that:

TermsFilter tf = new TermsFilter(); // it is in lucene-queries.jar
tf.addTerm(new Term("id", val1));
tf.addTerm(new Term("id", val2));
tf.addTerm(new Term("id", val3));
tf.addTerm(new Term("id", val4));
// if you need a query and don't want to use a Filter:
Query wrappedQ = new ConstantScoreQuery(tf);

You can execute the Filter as addon to your already prepared query:"content: (hello world)"), filter,...);

Or you use the wrapped as ConstantScore and combine it with the query:

BooleanQuery bq = new BooleanQuery();
bq.add(queryParser.parse("content: (hello world)"),
bq.add(wrapped, BooleanClause.Occur.MUST);,...);


Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen

> -----Original Message-----
> From: Praveen Yarlagadda []
> Sent: Wednesday, February 01, 2012 8:51 AM
> To:
> Subject: too many boolean clauses
> Hi all,
> I have been using lucene with Hibernate to index the data. Each document
> indexed with two fields: id and content. Each document corresponds to a
> in the database. In my usecase, search needs to work like this:
> 1. Fetch records from the database based on some criteria 2. Search for
> keywords only in the records found above
> I am preparing the search query like this: +(content: (hello world)) +(id:
> (234 235 899 534 345 898))
> If the number of documents (in the identifier field) reaches more than
> search fails with "too many boolean clauses". I can't use range query.
> Is there any other way to prepare the search query? How do I search for
> keywords in select documents?
> If you have any suggestions, please let me know.
> Thanks,
> Praveen

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

View raw message