if (facetFields != null && !facetFields.isEmpty()) {
for (String facetField : facetFields) {
TermsFacetBuilder termsFacetBuilder = new TermsFacetBuilder(facetField);
termsFacetBuilder.size(facetLimit);
termsFacetBuilder.field(facetField);
if (facetSort != null && facetSort.equals("index")) {
termsFacetBuilder.order(TermsFacet.ComparatorType.TERM);
} else {
termsFacetBuilder.order(TermsFacet.ComparatorType.COUNT);