class ESUtils {

    public static List<Map<String, String>> getResourcesFromEs(String index, String targetType,
            Map<String, String> filter, List<String> fields) throws Exception {
        if (Strings.isNullOrEmpty(index) || Strings.isNullOrEmpty(targetType)) {
            throw new Exception("pac_es or targetType cannot be null");
        }
        String url = getEsUrl();
        if (Strings.isNullOrEmpty(url)) {
            throw new Exception("ES_URI not found in the enviroment variables, do define one end point for ES");
        }

        Map<String, Object> effectiveFilter = new HashMap<>();
        effectiveFilter.putAll(getFilterForType(targetType));
        if (null != filter) {
            effectiveFilter.putAll(filter);
        }
        logger.debug("querying ES for target type:" + targetType);
        Long totalDocs = getTotalDocumentCountForIndexAndType(url, index, targetType, effectiveFilter, null, null);
        logger.debug("total resource count" + totalDocs);
        List<Map<String, String>> details = getDataFromES(url, index.toLowerCase(), targetType.toLowerCase(),
                effectiveFilter, null, null, fields, 0, totalDocs);
        return details;
    }

}