@Override
    @SuppressWarnings("nls")
    public ResponseStatsSummaryBean getResponseStatsSummary(String organizationId, String apiId,
            String version, DateTime from, DateTime to) {
        ResponseStatsSummaryBean rval = new ResponseStatsSummaryBean();

        try {
            String query =
                    "{" +
                    "    \"query\": {" +
                    "        \"bool\": {" +
                    "            \"filter\": [{" +
                    "                \"term\": {" +
                    "                    \"apiOrgId\": \"{{apiOrgId}}\"" +
                    "                }" +
                    "            }, {" +
                    "                \"term\": {" +
                    "                    \"apiId\": \"{{apiId}}\"" +
                    "                }" +
                    "            }, {" +
                    "                \"term\": {" +
                    "                    \"apiVersion\": \"{{apiVersion}}\"" +
                    "                }" +
                    "            }, {" +
                    "                \"range\": {" +
                    "                    \"requestStart\": {" +
                    "                        \"gte\": \"{{from}}\"," +
                    "                        \"lte\": \"{{to}}\"" +
                    "                    }" +
                    "                }" +
                    "            }]" +
                    "        }" +
                    "    }," +
                    "    \"size\": 0," +
                    "    \"aggs\": {" +
                    "        \"total_failures\": {" +
                    "            \"filter\": {" +
                    "                \"term\": {" +
                    "                    \"failure\": true" +
                    "                }" +
                    "            }" +
                    "        }," +
                    "        \"total_errors\": {" +
                    "            \"filter\": {" +
                    "                \"term\": {" +
                    "                    \"error\": true" +
                    "                }" +
                    "            }" +
                    "        }" +
                    "    }" +
                    "}";

            Map<String, Object> params = new HashMap<>();
            params.put("from", MetricsAccessorHelper.formatDate(from));
            params.put("to", MetricsAccessorHelper.formatDate(to));
            params.put("apiOrgId", organizationId.replace('"', '_'));
            params.put("apiId", apiId.replace('"', '_'));
            params.put("apiVersion", version.replace('"', '_'));

            SearchResponse searchResponse = this.doSearchTemplateRequest(query, params);
            Aggregations aggregations = searchResponse.getAggregations();

            rval.setTotal(searchResponse.getHits().getTotalHits().value);
            rval.setFailures(((ParsedFilter) aggregations.get("total_failures")).getDocCount());
            rval.setErrors(((ParsedFilter) aggregations.get("total_errors")).getDocCount());

        } catch (IOException e) {
            LOGGER.error(e);
        }
        return rval;
    }
@see io.apiman.manager.api.core.IMetricsAccessor#getResponseStatsSummary(java.lang.String, java.lang.String, java.lang.String, org.joda.time.DateTime, org.joda.time.DateTime)
manager/api/es/src/main/java/io/apiman/manager/api/es/EsMetricsAccessor.java