use of org.elasticsearch.index.query.NotFilterBuilder in project bw-calendar-engine by Bedework.
the class TermOrTerms method makeFb.
FilterBuilder makeFb() {
final FilterBuilder fb;
if (!isTerms) {
final TermFilterBuilder tfb = FilterBuilders.termFilter(fldName, value);
if (filterName != null) {
tfb.filterName(filterName);
}
fb = tfb;
} else {
final List vals = (List) value;
FilterBuilder newFb = null;
if (anding) {
for (final Object o : vals) {
if (o instanceof MatchNone) {
// and false is always false
newFb = (FilterBuilder) o;
break;
}
}
} else {
for (final Object o : vals) {
if (o instanceof MatchAllFilterBuilder) {
// or true is always true
newFb = (FilterBuilder) o;
break;
}
}
}
if (newFb != null) {
fb = newFb;
} else {
final TermsFilterBuilder tfb = FilterBuilders.termsFilter(fldName, (Iterable<?>) value).execution(exec);
if (filterName != null) {
tfb.filterName(filterName);
}
fb = tfb;
}
}
if (!not) {
return fb;
}
if (fb instanceof MatchAllFilterBuilder) {
return new MatchNone();
}
if (fb instanceof MatchNone) {
return new MatchAllFilterBuilder();
}
return new NotFilterBuilder(fb);
}
Aggregations