lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <...@thetaphi.de>
Subject RE: too many boolean clauses
Date Wed, 01 Feb 2012 08:26:04 GMT
I would recommend to use TermsFilter (http://goo.gl/BC9eQ, 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:

searcher.search(queryParser.parse("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)"),
BooleanClause.Occur.MUST);
bq.add(wrapped, BooleanClause.Occur.MUST);
searcher.search(bq,...);

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Praveen Yarlagadda [mailto:praveen.yarlagadda@gmail.com]
> Sent: Wednesday, February 01, 2012 8:51 AM
> To: java-user@lucene.apache.org
> Subject: too many boolean clauses
> 
> Hi all,
> 
> I have been using lucene with Hibernate to index the data. Each document
is
> indexed with two fields: id and content. Each document corresponds to a
record
> 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
the
> 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
1024,
> 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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message