code: private FilterAggregationBuilder buildWhereAggregations(EntityMetadata entityMetadata, QueryBuilder filter)
      {
          filter = filter != null ? filter : QueryBuilders.matchAllQuery();
          FilterAggregationBuilder filteragg = AggregationBuilders.filter(ESConstants.AGGREGATION_NAME).filter(filter);
  
          return filteragg;
      }
docs: Builds the where aggregations.
  
  @param entityMetadata
  the entity metadata
  @param filter
  the filter
  @return the filter aggregation builder