}
@Override
public FacetBuilder getFacet() {
Assert.notEmpty(fields, "Please select at last one field !!!");
TermsFacetBuilder builder = FacetBuilders.termsFacet(getName()).fields(fields).size(size);
switch (order) {
case descTerm:
builder.order(TermsFacet.ComparatorType.REVERSE_TERM);
break;
case ascTerm:
builder.order(TermsFacet.ComparatorType.TERM);
break;
case ascCount:
builder.order(TermsFacet.ComparatorType.REVERSE_COUNT);
break;
default:
builder.order(TermsFacet.ComparatorType.COUNT);
}
if (ArrayUtils.isNotEmpty(excludeTerms)) {
builder.exclude(excludeTerms);
}
if (allTerms) {
builder.allTerms(allTerms);
}
if (StringUtils.isNotBlank(regex)) {
builder.regex(regex, regexFlag);
}
return builder;
}