io.searchbox.core.search.aggregation.TermsAggregation Java Examples

The following examples show how to use io.searchbox.core.search.aggregation.TermsAggregation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticSearchReportService.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public List<String> getTopFacetFields() {
    final String query = elasticClient.loadQueryFromFile("topFacetFields",
            getEsFilters(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getApplicationId(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.getFrom().toInstant().toEpochMilli(),
            this.getTo().toInstant().toEpochMilli(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper());

    final SearchResult searchResult = elasticClient.getQuery(query);
    final List<TermsAggregation.Entry> termEntries = searchResult.getAggregations().getTermsAggregation("facets").getBuckets();
    return termEntries.stream()
            .map(TermsAggregation.Entry::getKey)
            .collect(Collectors.toList());
}
 
Example #2
Source File: ElasticSearchReportService.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public LinkedHashMap<String, JsonObject> getTopSuggestionFields() {
    final String query = elasticClient.loadQueryFromFile("topSuggestionFields",
            getEsFilters(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getApplicationId(),
            this.configuration.getMessageWrapper(),
            this.getFrom().toInstant().toEpochMilli(),
            this.getTo().toInstant().toEpochMilli(),
            this.configuration.getMessageWrapper());

    final SearchResult searchResult = elasticClient.getQuery(query);
    final List<TermsAggregation.Entry> termEntries = searchResult.getAggregations()
            .getTermsAggregation("suggestionFields")
            .getBuckets();
    final List<String> suggestionFields = termEntries.stream()
            .map(TermsAggregation.Entry::getKey)
            .collect(Collectors.toList());

    return prepareScopeFilterResults(suggestionFields, "Suggest");
}
 
Example #3
Source File: ElasticSearchReportService.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public LinkedHashMap<String, Long> getTopQueries() {
    final String query = elasticClient.loadQueryFromFile("topQueries",
            getEsFilters(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getApplicationId(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.getFrom().toInstant().toEpochMilli(),
            this.getTo().toInstant().toEpochMilli(),
            this.configuration.getMessageWrapper());

    final SearchResult searchResult = elasticClient.getQuery(query);
    final List<TermsAggregation.Entry> termEntries = searchResult.getAggregations().getTermsAggregation("queries").getBuckets();
    final LinkedHashMap<String, Long> result = new LinkedHashMap<>();
    termEntries.stream().sorted(Comparator.comparingLong(TermsAggregation.Entry::getCount).reversed())
            .forEach(entry -> result.put(entry.getKey(), entry.getCount()));

    return result;
}
 
Example #4
Source File: ElasticSearchReportService.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public LinkedHashMap<String, Long> getTopFilteredQueries() {
    final String query = elasticClient.loadQueryFromFile("topFilteredQueries",
            getEsFilters(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getApplicationId(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getReportWriterConfiguration().getQueryFilter(),
            this.configuration.getMessageWrapper(),
            this.getFrom().toInstant().toEpochMilli(),
            this.getTo().toInstant().toEpochMilli(),
            this.configuration.getMessageWrapper());


    final SearchResult searchResult = elasticClient.getQuery(query);
    final List<TermsAggregation.Entry> termEntries = searchResult.getAggregations().getTermsAggregation("queries").getBuckets();
    final LinkedHashMap<String, Long> result = new LinkedHashMap<>();
    termEntries.stream().sorted(Comparator.comparingLong(TermsAggregation.Entry::getCount).reversed())
            .forEach(entry -> result.put(entry.getKey(), entry.getCount()));

    return result;
}
 
Example #5
Source File: ElasticSearchReportService.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public LinkedHashMap<String, JsonObject> getTopFilterFields() {
    final String query = elasticClient.loadQueryFromFile("topFilterFields",
            getEsFilters(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getApplicationId(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.getFrom().toInstant().toEpochMilli(),
            this.getTo().toInstant().toEpochMilli(),
            this.configuration.getMessageWrapper());

    final SearchResult searchResult = elasticClient.getQuery(query);
    final List<TermsAggregation.Entry> termEntries = searchResult.getAggregations()
            .getTermsAggregation("filterFields")
            .getBuckets();
    final List<String> filterFields = termEntries.stream()
            .map(TermsAggregation.Entry::getKey)
            .collect(Collectors.toList());

    return prepareScopeFilterResults(filterFields, "Filter");
}
 
Example #6
Source File: ElasticsearchHelper.java    From herd with Apache License 2.0 6 votes vote down vote up
/**
 * Creates result type facet response dto
 *
 * @param searchResult search result
 *
 * @return result type facet response dto list
 */
public List<ResultTypeIndexSearchResponseDto> getResultTypeIndexSearchResponseDto(SearchResult searchResult)
{
    MetricAggregation metricAggregation = searchResult.getAggregations();
    TermsAggregation resultTypeAggregation = metricAggregation.getTermsAggregation(RESULT_TYPE_AGGS);

    List<TermsAggregation.Entry> buckets = resultTypeAggregation.getBuckets();

    List<ResultTypeIndexSearchResponseDto> resultTypeIndexSearchResponseDtos = new ArrayList<>();

    for (TermsAggregation.Entry entry : buckets)
    {
        ResultTypeIndexSearchResponseDto dto = new ResultTypeIndexSearchResponseDto();
        dto.setResultTypeCode(entry.getKeyAsString());
        dto.setResultTypeDisplayName(entry.getKeyAsString());
        dto.setCount(entry.getCount());
        resultTypeIndexSearchResponseDtos.add(dto);
    }

    return resultTypeIndexSearchResponseDtos;
}
 
Example #7
Source File: ElasticSearchReportService.java    From vind with Apache License 2.0 6 votes vote down vote up
@Override
public LinkedHashMap<String, Long> getTopUsers() {
    final String query = elasticClient.loadQueryFromFile("topUsers",
            getEsFilters(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getApplicationId(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.configuration.getMessageWrapper(),
            this.getFrom().toInstant().toEpochMilli(),
            this.getTo().toInstant().toEpochMilli(),
            this.configuration.getMessageWrapper());

    final SearchResult searchResult = elasticClient.getQuery(query);
    final List<TermsAggregation.Entry> termEntries = searchResult.getAggregations().getTermsAggregation("user").getBuckets();
    final LinkedHashMap<String, Long> result = new LinkedHashMap<>();
    termEntries.stream().sorted(Comparator.comparingLong(TermsAggregation.Entry::getCount).reversed())
            .forEach(entry -> result.put(entry.getKey(), entry.getCount()));

    return result;
}
 
Example #8
Source File: ElasticSearchHelperTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetResultTypeIndexSearchResponseDtoSearchResult()
{
    SearchResult searchResult = mock(SearchResult.class);
    MetricAggregation metricAggregation = mock(MetricAggregation.class);
    TermsAggregation termsAggregation = mock(TermsAggregation.class);
    List<TermsAggregation.Entry> buckets = new ArrayList<>();
    buckets.add(new TermsAggregation("TermAggregation", new JsonObject()).new Entry(new JsonObject(), "key", 1L));

    when(searchResult.getAggregations()).thenReturn(metricAggregation);
    when(metricAggregation.getTermsAggregation(RESULT_TYPE_AGGS)).thenReturn(termsAggregation);
    when(termsAggregation.getBuckets()).thenReturn(buckets);

    List<ResultTypeIndexSearchResponseDto> result = elasticsearchHelper.getResultTypeIndexSearchResponseDto(searchResult);
    assertThat("Result is null.", result, is(notNullValue()));
}
 
Example #9
Source File: ElasticsearchHelper.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * create tag tag index response dto
 *
 * @param searchResult search result
 *
 * @return tag type index search response dto list
 */
public List<TagTypeIndexSearchResponseDto> getNestedTagTagIndexSearchResponseDto(SearchResult searchResult)
{
    MetricAggregation metricAggregation = searchResult.getAggregations();
    MetricAggregation tagFacetAggregation = metricAggregation.getSumAggregation(TAG_FACET_AGGS);
    TermsAggregation tagTypeCodesAggregation = tagFacetAggregation.getTermsAggregation(TAGTYPE_CODE_AGGREGATION);
    return getTagTypeIndexSearchResponseDtosFromTermsAggregation(tagTypeCodesAggregation);
}
 
Example #10
Source File: ElasticSearchHelperTest.java    From herd with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetNestedTagTagIndexSearchResponseDtoSearchResultParameter()
{
    SearchResult searchResult = mock(SearchResult.class);
    MetricAggregation metricAggregation = mock(MetricAggregation.class);
    SumAggregation tagFacetAggregation = mock(SumAggregation.class);
    TermsAggregation tagTypeCodesAggregation = mock(TermsAggregation.class);

    when(searchResult.getAggregations()).thenReturn(metricAggregation);
    when(metricAggregation.getSumAggregation(TAG_FACET_AGGS)).thenReturn(tagFacetAggregation);
    when(tagFacetAggregation.getTermsAggregation(TAGTYPE_CODE_AGGREGATION)).thenReturn(tagTypeCodesAggregation);

    List<TagTypeIndexSearchResponseDto> result = elasticsearchHelper.getNestedTagTagIndexSearchResponseDto(searchResult);
    assertThat("Result is null.", result, is(notNullValue()));
}
 
Example #11
Source File: ESRegistry.java    From apiman with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("nls")
public void listOrgs(IAsyncResultHandler<List<String>> handler) {
    try {
        String query =
                "{\n" +
                "    \"aggs\" : {\n" +
                "        \"all_orgs\" : {\n" +
                "            \"terms\" : { \"field\" : \"organizationId\" }\n" + // i.e. only records containing an orgId field.
                "        }\n" +
                "    }\n" +
                "}";
        Search search = new Search.Builder(query)
                .addIndex(getIndexName())
                .setParameter(Parameters.SIZE, 0)
                .build();
        SearchResult response = getClient().execute(search);
        // Aggregations section
        MetricAggregation aggregation = response.getAggregations();
        // Look at the terms subsection
        TermsAggregation terms = aggregation.getTermsAggregation("all_orgs");
        // Grab only the name of each aggregation (we don't care about count
        List<String> results = terms.getBuckets().stream()
                .map(TermsAggregation.Entry::getKey)
                .collect(Collectors.toList());
        handler.handle(AsyncResultImpl.create(results));
    } catch (IOException e) {
        handler.handle(AsyncResultImpl.create(e));
    }
}
 
Example #12
Source File: ESRegistry.java    From apiman with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("nls")
public void listApiVersions(String organizationId, String apiId, int page, int pageSize,
                            IAsyncResultHandler<List<String>> handler) {
    try {
        String query = "{" +
                "  \"query\": {" +
                "    \"bool\": {" +
                "      \"filter\": [" +
                "        {" +
                "          \"term\": {" +
                "            \"organizationId\": ?" + // organizationId
                "          }" +
                "        }," +
                "        {" +
                "          \"term\": {" +
                "            \"apiId\": ?" + // apiId
                "          }" +
                "        }" +
                "      ]" +
                "    }" +
                "  }," +
                "    \"aggs\": {" +
                "      \"api_versions\": {" +
                "        \"terms\": {" +
                "          \"field\": \"version\"" + // only return version fields of APIs
                "        }" +
                "      }" +
                "    }" +
                "}";
        String escaped = ESUtils.queryWithEscapedArgs(query, organizationId, apiId);
        Search search = new Search.Builder(escaped)
                .addIndex(getIndexName())
                .addType("api")
                .setParameter(Parameters.SIZE, 0)
                .build();
        SearchResult response = getClient().execute(search);
        // Aggregations section
        MetricAggregation aggregation = response.getAggregations();
        // Look at the terms subsection
        TermsAggregation terms = aggregation.getTermsAggregation("api_versions");
        // Grab only the name of each aggregation
        List<String> results = terms.getBuckets().stream()
                .map(TermsAggregation.Entry::getKey)
                .collect(Collectors.toList());
        handler.handle(AsyncResultImpl.create(results));
    } catch (IOException e) {
        handler.handle(AsyncResultImpl.create(e));
    }
}
 
Example #13
Source File: ESRegistry.java    From apiman with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("nls")
public void listClientVersions(String organizationId, String clientId, int page, int pageSize, IAsyncResultHandler<List<String>> handler) {
    try {
        String query = "{" +
                "  \"query\": {" +
                "    \"bool\": {" +
                "      \"filter\": [" +
                "        {" +
                "          \"term\": {" +
                "            \"organizationId\": ?" +  // organizationId
                "          }" +
                "        }," +
                "        {" +
                "          \"term\": {" +
                "            \"clientId\": ?" + // clientId
                "          }" +
                "        }" +
                "      ]" +
                "    }" +
                "  }," +
                "    \"aggs\": {" +
                "      \"client_versions\": {" +
                "        \"terms\": {" +
                "          \"field\": \"version\"" + // only return version fields of clients
                "        }" +
                "      }" +
                "    }" +
                "}";

        String escaped = ESUtils.queryWithEscapedArgs(query, organizationId, clientId);
        Search search = new Search.Builder(escaped)
                .addIndex(getIndexName())
                .addType("client")
                .setParameter(Parameters.SIZE, 0) // size zero to return only aggregate data (not raw query results)
                .build();
        SearchResult response = getClient().execute(search);
        // Aggregations section
        MetricAggregation aggregation = response.getAggregations();
        // Look at the terms subsection
        TermsAggregation terms = aggregation.getTermsAggregation("client_versions");
        // Grab only the name of each aggregation
        List<String> results = terms.getBuckets().stream()
                .map(TermsAggregation.Entry::getKey)
                .collect(Collectors.toList());
        handler.handle(AsyncResultImpl.create(results));
    } catch (IOException e) {
        handler.handle(AsyncResultImpl.create(e));
    }
}
 
Example #14
Source File: ESRegistry.java    From apiman with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("nls")
@Override
public void listApis(String organizationId, int page, int pageSize, IAsyncResultHandler<List<String>> handler) {
    try {
        String query = "{" +
                "      \"query\": {" +
                "        \"bool\": {" +
                "          \"filter\": [" +
                "            {" +
                "              \"exists\": {" +
                "                \"field\": \"apiId\" " + // must have field apiId
                "              }" +
                "            }," +
                "            {" +
                "              \"term\": {" +
                "                \"organizationId\": ? " +  // organizationId
                "              }" +
                "            }" +
                "          ]" +
                "        }" +
                "    }," +
                "    \"aggs\": {" +
                "        \"apis\": {" +
                "            \"terms\": {" +
                "                \"field\": \"apiId\" " + // only return aggregated apiId field
                "            }" +
                "        }" +
                "    }" +
                "}";
        String escaped = ESUtils.queryWithEscapedArgs(query, organizationId);
        Search search = new Search.Builder(escaped)
                .addIndex(getIndexName())
                .addType("api")
                .setParameter(Parameters.SIZE, 0)
                .build();
        SearchResult response = getClient().execute(search);
        // Aggregations section
        MetricAggregation aggregation = response.getAggregations();
        // Look at the terms subsection
        TermsAggregation terms = aggregation.getTermsAggregation("apis");
        // Grab only the name of each aggregation (we don't care about count [for now]).
        List<String> results = terms.getBuckets().stream()
                .map(TermsAggregation.Entry::getKey)
                .collect(Collectors.toList());
        handler.handle(AsyncResultImpl.create(results));
    } catch (IOException e) {
        handler.handle(AsyncResultImpl.create(e));
    }
}
 
Example #15
Source File: ESRegistry.java    From apiman with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("nls")
public void listClients(String organizationId, int page, int pageSize, IAsyncResultHandler<List<String>> handler) {
    try {
        String query = "{" +
                "      \"query\": {" +
                "        \"bool\": {" +
                "          \"filter\": [" +
                "            {" +
                "              \"exists\": {" +
                "                \"field\": \"clientId\" " + // clientId
                "              }" +
                "            }," +
                "            {" +
                "              \"term\": {" +
                "                \"organizationId\": ? " +  // organizationId
                "              }" +
                "            }" +
                "          ]" +
                "        }" +
                "    }," +
                "    \"aggs\": {" +
                "        \"clients\": {" +
                "            \"terms\": {" +
                "                \"field\": \"clientId\" " + // only return aggregated clientId field
                "            }" +
                "        }" +
                "    }" +
                "}";
        String escaped = ESUtils.queryWithEscapedArgs(query, organizationId);
        Search search = new Search.Builder(escaped)
                .addIndex(getIndexName())
                .addType("client")
                .setParameter(Parameters.SIZE, 0)
                .build();
        SearchResult response = getClient().execute(search);
        // Aggregations section
        MetricAggregation aggregation = response.getAggregations();
        // Look at the terms subsection
        TermsAggregation terms = aggregation.getTermsAggregation("clients");
        // Grab only the name of each aggregation (we don't care about count [for now]).
        List<String> results = terms.getBuckets().stream()
                .map(TermsAggregation.Entry::getKey)
                .collect(Collectors.toList());
        handler.handle(AsyncResultImpl.create(results));
    } catch (IOException e) {
        handler.handle(AsyncResultImpl.create(e));
    }
}
 
Example #16
Source File: ElasticSearchHelperTest.java    From herd with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetTagTagIndexSearchResponseDtoSearchResult()
{
    SearchResult searchResult = mock(SearchResult.class);
    MetricAggregation metricAggregation = mock(MetricAggregation.class);
    TermsAggregation termsAggregation = mock(TermsAggregation.class);

    when(searchResult.getAggregations()).thenReturn(metricAggregation);
    when(metricAggregation.getTermsAggregation(TAG_TYPE_FACET_AGGS)).thenReturn(termsAggregation);

    List<TermsAggregation.Entry> buckets = new ArrayList<>();
    TermsAggregation.Entry entryL1 = mock(TermsAggregation.Entry.class);
    buckets.add(entryL1);
    when(termsAggregation.getBuckets()).thenReturn(buckets);

    TermsAggregation termsAggregationL1 = mock(TermsAggregation.class);
    when(entryL1.getTermsAggregation(TAGTYPE_NAME_AGGREGATION)).thenReturn(termsAggregationL1);

    List<TermsAggregation.Entry> bucketsL1 = new ArrayList<>();
    TermsAggregation.Entry entryL2 = mock(TermsAggregation.Entry.class);
    bucketsL1.add(entryL2);
    when(termsAggregationL1.getBuckets()).thenReturn(bucketsL1);

    TermsAggregation entryTermsAggregation = mock(TermsAggregation.class);
    when(entryL2.getTermsAggregation(TAG_CODE_AGGREGATION)).thenReturn(entryTermsAggregation);

    List<TermsAggregation.Entry> bucketsL2 = new ArrayList<>();
    TermsAggregation.Entry entryL3 = mock(TermsAggregation.Entry.class);
    bucketsL2.add(entryL3);
    when(entryTermsAggregation.getBuckets()).thenReturn(bucketsL2);

    TermsAggregation entryEntryTermsAggregation = mock(TermsAggregation.class);
    when(entryL3.getTermsAggregation(TAG_NAME_AGGREGATION)).thenReturn(entryEntryTermsAggregation);

    List<TermsAggregation.Entry> bucketsL3 = new ArrayList<>();
    TermsAggregation.Entry entryL4 = mock(TermsAggregation.Entry.class);
    bucketsL3.add(entryL4);
    when(entryEntryTermsAggregation.getBuckets()).thenReturn(bucketsL3);

    List<TagTypeIndexSearchResponseDto> result = elasticsearchHelper.getTagTagIndexSearchResponseDto(searchResult);
    assertThat("Result is null.", result, is(notNullValue()));
}
 
Example #17
Source File: ElasticsearchHelper.java    From herd with Apache License 2.0 4 votes vote down vote up
/**
 * get Tag Type index response
 *
 * @param termsAggregation termsAggregation
 *
 * @return list of tag type index search dto
 */
private List<TagTypeIndexSearchResponseDto> getTagTypeIndexSearchResponseDtosFromTermsAggregation(TermsAggregation termsAggregation)
{
    List<TermsAggregation.Entry> bucketsL0 = termsAggregation.getBuckets();

    List<TagTypeIndexSearchResponseDto> tagTypeIndexSearchResponseDtos = new ArrayList<>();

    for (TermsAggregation.Entry entryL1 : bucketsL0)
    {
        List<TagIndexSearchResponseDto> tagIndexSearchResponseDtos = new ArrayList<>();

        TermsAggregation termsAggregationL1 = entryL1.getTermsAggregation(TAGTYPE_NAME_AGGREGATION);
        List<TermsAggregation.Entry> bucketsL1 = termsAggregationL1.getBuckets();

        TagTypeIndexSearchResponseDto tagTypeIndexSearchResponseDto =
            new TagTypeIndexSearchResponseDto(entryL1.getKeyAsString(), tagIndexSearchResponseDtos, null);

        tagTypeIndexSearchResponseDtos.add(tagTypeIndexSearchResponseDto);

        for (TermsAggregation.Entry entryL2 : bucketsL1)
        {
            tagTypeIndexSearchResponseDto.setDisplayName(entryL2.getKeyAsString());
            TermsAggregation entryTermsAggregation = entryL2.getTermsAggregation(TAG_CODE_AGGREGATION);
            List<TermsAggregation.Entry> bucketsL2 = entryTermsAggregation.getBuckets();

            for (TermsAggregation.Entry entryL3 : bucketsL2)
            {
                TagIndexSearchResponseDto tagIndexSearchResponseDto = new TagIndexSearchResponseDto(entryL3.getKeyAsString(), entryL3.getCount(), null);
                tagIndexSearchResponseDtos.add(tagIndexSearchResponseDto);
                TermsAggregation entryEntryTermsAggregation = entryL3.getTermsAggregation(TAG_NAME_AGGREGATION);

                List<TermsAggregation.Entry> bucketsL3 = entryEntryTermsAggregation.getBuckets();

                for (TermsAggregation.Entry entryL4 : bucketsL3)
                {
                    tagIndexSearchResponseDto.setTagDisplayName(entryL4.getKeyAsString());
                }
            }
        }
    }

    return tagTypeIndexSearchResponseDtos;
}
 
Example #18
Source File: ElasticsearchHelper.java    From herd with Apache License 2.0 3 votes vote down vote up
/**
 * get tag index search response dto
 *
 * @param searchResult elastic search result
 *
 * @return list of tag type index search response dto
 */
public List<TagTypeIndexSearchResponseDto> getTagTagIndexSearchResponseDto(SearchResult searchResult)
{
    MetricAggregation metricAggregation = searchResult.getAggregations();
    TermsAggregation tagTypeFacetAggregation = metricAggregation.getTermsAggregation(TAG_TYPE_FACET_AGGS);
    return getTagTypeIndexSearchResponseDtosFromTermsAggregation(tagTypeFacetAggregation);
}