lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject query matching all documents
Date Fri, 09 May 2003 23:50:02 GMT

Is there a query object which can match all documents?

As an example, suppose my search supports zero or more search criteria.  
Each criteria, if specified, is required to match the document.  If no 
criteria are specified, all documents should be returned.  Here's an 
example (NullQuery is an imaginary class which represents the query type 
I'm looking for):

BooleanQuery query = new BooleanQuery();
query.add(new NullQuery(), true, false);
if (criteria1exists) {
  query.add(..., true, false);
if (criteria2exists) {
  query.add(..., true, false);

Without line 2, if no criteria is specified, no documents will be 
returned.  Apparently, a boolean query with no boolean elements matches 
zero documents.  In my opinion, it would have made more sense for it to 
match all documents, since each boolean element represents a constraint, 
and no constraints implies all documents.  But for clarity, maybe there 
should be an AllQuery and a NoneQuery which match all documents and no 
documents respectively.

But back to reality, is there a way to achieve this with the existing 
query classes?  I'd prefer not to add a dummy field to search by, as 
this is not efficient.


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

View raw message