final int nbrOfClauses = clauses.size();
if ( nbrOfClauses == 0 ) {
throw new AssertionFailure( "Cannot create an empty boolean query" );
}
else if ( nbrOfClauses == 1 ) {
final BooleanClause uniqueClause = clauses.get( 0 );
if ( uniqueClause.getOccur().equals( BooleanClause.Occur.MUST_NOT ) ) {
//FIXME We have two choices here, raise an exception or combine with an All query. #2 is done atm.
//TODO which normfield to use and how to pass it?
should( new MatchAllDocsQuery() );
}
else {
//optimize
return queryCustomizer.setWrappedQuery( uniqueClause.getQuery() ).createQuery();
}
}
BooleanQuery query = new BooleanQuery();
for ( BooleanClause clause : clauses ) {