ElasticsearchHelper { public SearchRequestBuilder addFacetFieldAggregations(Set<String> facetFieldsList, SearchRequestBuilder searchRequestBuilder) { if (CollectionUtils.isNotEmpty(facetFieldsList)) { if (facetFieldsList.contains(TAG_FACET)) { searchRequestBuilder.addAggregation(AggregationBuilders.nested(TAG_FACET_AGGS, NESTED_BDEFTAGS_PATH).subAggregation( AggregationBuilders.terms(TAGTYPE_CODE_AGGREGATION).field(BDEF_TAGTYPE_CODE_FIELD).subAggregation( AggregationBuilders.terms(TAGTYPE_NAME_AGGREGATION).field(BDEF_TAGTYPE_NAME_FIELD).subAggregation( AggregationBuilders.terms(TAG_CODE_AGGREGATION).field(BDEF_TAG_CODE_FIELD) .subAggregation(AggregationBuilders.terms(TAG_NAME_AGGREGATION).field(BDEF_TAG_NAME_FIELD)))))); searchRequestBuilder.addAggregation(AggregationBuilders.terms(TAG_TYPE_FACET_AGGS).field(TAGTYPE_CODE_FIELD_TAG_INDEX).subAggregation( AggregationBuilders.terms(TAGTYPE_NAME_AGGREGATION).field(TAGTYPE_NAME_FIELD_TAG_INDEX).subAggregation( AggregationBuilders.terms(TAG_CODE_AGGREGATION).field(TAG_CODE_FIELD_TAG_INDEX) .subAggregation(AggregationBuilders.terms(TAG_NAME_AGGREGATION).field(TAG_NAME_FIELD_TAG_INDEX))))); } if (facetFieldsList.contains(RESULT_TYPE_FACET)) { searchRequestBuilder.addAggregation(AggregationBuilders.terms(RESULT_TYPE_AGGS).field(RESULT_TYPE_FIELD)); } } return searchRequestBuilder; }  SearchRequestBuilder addFacetFieldAggregations(Set<String> facetFieldsList, SearchRequestBuilder searchRequestBuilder); BoolQueryBuilder addIndexSearchFilterBooleanClause(List<IndexSearchFilter> indexSearchFilters, String bdefActiveIndex, String tagActiveIndex); List<ResultTypeIndexSearchResponseDto> getResultTypeIndexSearchResponseDto(SearchResponse searchResponse); List<TagTypeIndexSearchResponseDto> getTagTagIndexSearchResponseDto(SearchResponse searchResponse); List<TagTypeIndexSearchResponseDto> getNestedTagTagIndexSearchResponseDto(SearchResponse searchResponse); List<Facet> getFacetsResponse(ElasticsearchResponseDto elasticsearchResponseDto, final String bdefActiveIndex, final String tagActiveIndex); Terms getAggregation(SearchResponse searchResponse, String aggregationName); Terms getNestedAggregation(SearchResponse searchResponse, String nestedAggregationName, String subAggregationName); String getSearchIndexType(final String indexName, final String bdefActiveIndex, final String tagActiveIndex); static final String DISPLAY_NAME_SOURCE; static final String NESTED_BDEFTAGS_PATH; static final String TAGTYPE_CODE_FIELD_TAG_INDEX; static final String TAGTYPE_NAME_FIELD_TAG_INDEX; static final String TAG_CODE_FIELD_TAG_INDEX; static final String TAG_NAME_FIELD_TAG_INDEX; static final String BDEF_TAGTYPE_CODE_FIELD; static final String BDEF_TAGTYPE_NAME_FIELD; static final String BDEF_TAG_CODE_FIELD; static final String BDEF_TAG_NAME_FIELD; static final String TAG_TAG_CODE_FIELD; static final String TAG_TAGTYPE_CODE_FIELD; static final String TAG_FACET_AGGS; static final String TAGTYPE_CODE_AGGREGATION; static final String TAGTYPE_NAME_AGGREGATION; static final String TAG_CODE_AGGREGATION; static final String TAG_NAME_AGGREGATION; static final String TAG_FACET; static final String RESULT_TYPE_FACET; static final String TAG_TYPE_FACET_AGGS; static final String RESULT_TYPE_AGGS; static final String RESULT_TYPE_FIELD; }
@Test public void testAddFacetFieldAggregationsWithFacetFields() { Set<String> facetFieldsList = new HashSet<>(); facetFieldsList.add(TAG_FACET); facetFieldsList.add(RESULT_TYPE_FACET); SearchRequestBuilder searchRequestBuilder = mock(SearchRequestBuilder.class); SearchRequestBuilder result = elasticsearchHelper.addFacetFieldAggregations(facetFieldsList, searchRequestBuilder); assertThat("Result is null.", result, is(notNullValue())); }
@Test public void testAddFacetFieldAggregations() { Set<String> facetSet = new HashSet<>(); elasticsearchHelper.addFacetFieldAggregations(facetSet, null); }