* of the supplied conditions should match in the result set.
*/
if (condition.getSpecifier().isNegation() && !matchAllConditions) {
BooleanQuery nestedquery = new BooleanQuery();
nestedquery.add(clause);
nestedquery.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST));
fieldQuery.add(new BooleanClause(nestedquery, Occur.SHOULD));
}
/* Normal Case */
else {
fieldQuery.add(clause);
}
}
/* Add the MatchAllDocsQuery (MUST_NOT is used, All Conditions match) */
if (fieldQuery != null && matchAllConditions) {
boolean requireAllDocsQuery = true;
BooleanClause[] clauses = fieldQuery.getClauses();
for (BooleanClause clause : clauses) {
if (clause.getOccur() != Occur.MUST_NOT) {
requireAllDocsQuery = false;
break;
}
}
/* Add if required */
if (requireAllDocsQuery)
fieldQuery.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST));
}
/* Use custom hit collector for performance reasons */
final List<SearchHit<NewsReference>> resultList = new ArrayList<SearchHit<NewsReference>>();
HitCollector collector = new HitCollector() {