class TaggingRepositoryImpl implements TaggingRepository, Constants {

    public String getUntaggedTargetTypeIssues(
            UntaggedTargetTypeRequest request, List<String> tagsList)
            throws DataException {
        String assetGroup = request.getAg();
        StringBuilder urlToQueryBuffer = new StringBuilder(esUrl).append("/")
                .append(assetGroup).append("/").append(SEARCH);
        StringBuilder requestBody = null;
        String body = "{\"query\":{\"bool\":{\"must\":[{\"term\":{\"type.keyword\":{\"value\":\"issue\"}}},{\"term\":{\"policyId.keyword\":{\"value\":\""
                + TAGGIG_POLICY
                + "\"}}},{\"term\":{\"issueStatus.keyword\":{\"value\":\"open\"}}}]";

        if (!tagsList.isEmpty()) {
            body = body + ",\"should\":[";
            /* filtering by tags */
            for (String tag : tagsList) {
                body = body + "{\"match_phrase_prefix\":{\"missingTags\":\""
                        + tag + "\"}},";
            }
            body = body.substring(0, body.length() - 1);
            body = body + "]";
            body = body + ",\"minimum_should_match\":1";
        }
        body = body
                + "}},\"aggs\":{\"NAME\":{\"terms\":{\"field\":\"targetType.keyword\",\"size\":1000}}}}";
        requestBody = new StringBuilder(body);
     try{   return PacHttpUtils.doHttpPost(urlToQueryBuffer.toString(),
                requestBody.toString());
     } catch (Exception e) {
         logger.error(e.getMessage());
         throw new DataException(e);
     }
    }

}