Add BoolFilterBuilder#hasClauses to be consitent with BoolQueryBuilder

Closes #5472
This commit is contained in:
Simon Willnauer 2014-03-20 13:05:04 +01:00
parent bd003fe5b6
commit 047119d92e
2 changed files with 11 additions and 6 deletions

View File

@ -19,15 +19,11 @@
package org.elasticsearch.index.query;
import org.apache.lucene.search.BooleanClause;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.ToXContent.Params;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A filter that matches documents matching boolean combinations of other filters.
@ -103,6 +99,14 @@ public class BoolFilterBuilder extends BaseFilterBuilder {
}
return this;
}
/**
* Returns <code>true</code> iff this filter builder has at least one should, must or mustNot clause.
* Otherwise <code>false</code>.
*/
public boolean hasClauses() {
return !(mustClauses.isEmpty() && shouldClauses.isEmpty() && mustNotClauses.isEmpty());
}
/**
* Sets the filter name for the filter that can be used when searching for matched_filters per hit.

View File

@ -119,10 +119,11 @@ public class BoolQueryBuilder extends BaseQueryBuilder implements BoostableQuery
}
/**
* Return <code>true</code> if the query being built has no clause yet
* Returns <code>true</code> iff this query builder has at least one should, must or mustNot clause.
* Otherwise <code>false</code>.
*/
public boolean hasClauses() {
return !mustClauses.isEmpty() || !mustNotClauses.isEmpty() || !shouldClauses.isEmpty();
return !(mustClauses.isEmpty() && shouldClauses.isEmpty() && mustNotClauses.isEmpty());
}
/**