class TaggingRepositoryImpl implements TaggingRepository, Constants {

    public JsonArray getUntaggedIssuesByapplicationFromES(String assetGroup,
            String mandatoryTags, String searchText, int from, int size)
            throws DataException {
    	List<String> mandatoryTagsList  = new ArrayList<>();
    	if(!com.amazonaws.util.StringUtils.isNullOrEmpty(mandatoryTags)){
       mandatoryTagsList = Arrays
                .asList(mandatoryTags.split(","));
    	}
        String responseJson = null;
        JsonParser jsonParser;
        JsonObject resultJson;
        StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/")
                .append(assetGroup).append("/").append(SEARCH);
        StringBuilder requestBody = new StringBuilder(
                "{\"size\":0,\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"policyId.keyword\":{\"value\":\"PacMan_TaggingRule_version-1\"}}}");
        if (!Strings.isNullOrEmpty(searchText)) {
            requestBody.append("," + "{\"match_phrase_prefix\":{\"_all\":\""
                    + searchText + "\"" + "}}");
        }

        requestBody
                .append("],\"should\":[{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}}],\"minimum_should_match\":1}},\"aggs\":{\"apps\":{\"terms\":{\"field\":\"tags.Application.keyword\",\"size\":"
                        + pageSize
                        + "},\"aggs\":{\"tags\":{\"filters\":{\"filters\":{");

        for (String tags : mandatoryTagsList) {
            if (!"Application".equalsIgnoreCase(tags)) {
                requestBody.append("\"" + tags + "\""
                        + ":{\"bool\":{\"must\":[{\"match\":{\"missingTags\":"
                        + "\"" + tags + "\"" + "}}]}},");

            }
        }
        requestBody.setLength(requestBody.length() - 1);
        requestBody.append("}}}}}}}");
        try{
        responseJson = PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(),
                requestBody.toString());
        } catch (Exception e) {
            throw new DataException(e);
        }
        jsonParser = new JsonParser();
        resultJson = (JsonObject) jsonParser.parse(responseJson);
        JsonObject aggsJson = (JsonObject) jsonParser.parse(resultJson.get(
                AGGREGATIONS).toString());
        return aggsJson.getAsJsonObject("apps").getAsJsonArray(BUCKETS);
    }

}