blueflood-elasticsearch/src/main/java/com/rackspacecloud/blueflood/io/AbstractElasticIO.java
private String getMetricNamesFromES(final String tenant, final String regexMetricName) throws IOException {
        String metricNamesFromElasticsearchQueryString = String.format(queryToFetchMetricNamesFromElasticsearchFormat,
                tenant, regexMetricName, regexMetricName);

        return elasticsearchRestHelper.fetchDocuments(
                ELASTICSEARCH_INDEX_NAME_READ,
                ELASTICSEARCH_DOCUMENT_TYPE,
                tenant,
                metricNamesFromElasticsearchQueryString);
    }
private String getMetricNamesFromES(final String tenant, final String regexMetricName) throws IOException {
        String metricNamesFromElasticsearchQueryString = String.format(queryToFetchMetricNamesFromElasticsearchFormat,
                tenant, regexMetricName, regexMetricName);

        return elasticsearchRestHelper.fetchDocuments(
                ELASTICSEARCH_INDEX_NAME_READ,
                ELASTICSEARCH_DOCUMENT_TYPE,
                tenant,
                metricNamesFromElasticsearchQueryString);
    }
private String getMetricNamesFromES ( final String tenant , final String regexMetricName ) throws IOException { String metricNamesFromElasticsearchQueryString = String . format ( queryToFetchMetricNamesFromElasticsearchFormat , tenant , regexMetricName , regexMetricName ) ; return elasticsearchRestHelper . fetchDocuments ( ELASTICSEARCH_INDEX_NAME_READ , ELASTICSEARCH_DOCUMENT_TYPE , tenant , metricNamesFromElasticsearchQueryString ) ; }
Performs terms aggregation by metric_name which returns doc_count by
metric_name index that matches the given regex.

Sample request body:

{
"size": 0,
"query": {
"bool" : {
"must" : [ {
"term" : {
"tenantId" : "ratanasv"
}
}, {
"regexp" : {
"metric_name" : {
"value" : "<regex>"
}
}
} ]
}
},
"aggs": {
"metric_name_tokens": {
"terms": {
"field" : "metric_name",
"include": "<regex>",
"execution_hint": "map",
"size": 0
}
}
}
}

The two regex expressions used in the query above would be same, one to filter
at query level and another to filter the aggregation buckets.

Execution hint of "map" works by using field values directly instead of ordinals
in order to aggregate data per-bucket

@param tenant
@param regexMetricName
@return
Performs terms aggregation by metric_name which returns doc_count by metric_name index that matches the given regex .