use of org.finra.herd.model.dto.ResultTypeIndexSearchResponseDto in project herd by FINRAOS.
the class ElasticsearchHelper method getFacetsResponse.
/**
* get the facets in the response
*
* @param elasticsearchResponseDto elastic search response dto
* @param bdefActiveIndex the name of the active index for business object definitions
* @param tagActiveIndex the name os the active index for tags
*
* @return facets in the response dto
*/
public List<Facet> getFacetsResponse(ElasticsearchResponseDto elasticsearchResponseDto, final String bdefActiveIndex, final String tagActiveIndex) {
List<Facet> facets = new ArrayList<>();
List<Facet> tagTypeFacets;
if (elasticsearchResponseDto.getNestTagTypeIndexSearchResponseDtos() != null) {
tagTypeFacets = new ArrayList<>();
// construct a list of facet information
for (TagTypeIndexSearchResponseDto tagTypeIndexSearchResponseDto : elasticsearchResponseDto.getNestTagTypeIndexSearchResponseDtos()) {
tagTypeFacets.add(createTagTypeFacet(tagTypeIndexSearchResponseDto));
}
facets.addAll(tagTypeFacets);
}
if (elasticsearchResponseDto.getTagTypeIndexSearchResponseDtos() != null) {
for (TagTypeIndexSearchResponseDto tagTypeIndexDto : elasticsearchResponseDto.getTagTypeIndexSearchResponseDtos()) {
boolean foundMatchingTagType = false;
for (Facet tagFacet : facets) {
if (tagFacet.getFacetId().equals(tagTypeIndexDto.getCode())) {
foundMatchingTagType = true;
boolean foundMatchingTagCode = false;
for (TagIndexSearchResponseDto tagIndexDto : tagTypeIndexDto.getTagIndexSearchResponseDtos()) {
for (Facet nestedTagIndexDto : tagFacet.getFacets()) {
if (tagIndexDto.getTagCode().equals(nestedTagIndexDto.getFacetId())) {
foundMatchingTagCode = true;
}
}
if (!foundMatchingTagCode) {
tagFacet.getFacets().add(new Facet(tagIndexDto.getTagDisplayName(), tagIndexDto.getCount(), FacetTypeEnum.TAG.value(), tagIndexDto.getTagCode(), null));
}
}
}
}
if (!foundMatchingTagType) {
facets.add(createTagTypeFacet(tagTypeIndexDto));
}
}
}
if (elasticsearchResponseDto.getResultTypeIndexSearchResponseDtos() != null) {
List<Facet> resultTypeFacets = new ArrayList<>();
// construct a list of facet information
for (ResultTypeIndexSearchResponseDto resultTypeIndexSearchResponseDto : elasticsearchResponseDto.getResultTypeIndexSearchResponseDtos()) {
String facetId = getSearchIndexType(resultTypeIndexSearchResponseDto.getResultTypeDisplayName(), bdefActiveIndex, tagActiveIndex);
Facet resultTypeFacet = new Facet(facetId, resultTypeIndexSearchResponseDto.getCount(), FacetTypeEnum.RESULT_TYPE.value(), facetId, null);
resultTypeFacets.add(resultTypeFacet);
}
facets.addAll(resultTypeFacets);
}
return facets;
}
use of org.finra.herd.model.dto.ResultTypeIndexSearchResponseDto in project herd by FINRAOS.
the class ElasticsearchHelper method getResultTypeIndexSearchResponseDto.
/**
* Creates result type facet response dto
*
* @param searchResponse search response
*
* @return result type facet response dto list
*/
public List<ResultTypeIndexSearchResponseDto> getResultTypeIndexSearchResponseDto(SearchResponse searchResponse) {
List<ResultTypeIndexSearchResponseDto> list = new ArrayList<>();
Terms aggregation = getAggregation(searchResponse, RESULT_TYPE_AGGS);
for (Terms.Bucket resultTypeEntry : aggregation.getBuckets()) {
ResultTypeIndexSearchResponseDto dto = new ResultTypeIndexSearchResponseDto();
dto.setResultTypeCode(resultTypeEntry.getKeyAsString());
dto.setResultTypeDisplayName(resultTypeEntry.getKeyAsString());
dto.setCount(resultTypeEntry.getDocCount());
list.add(dto);
}
return list;
}
Aggregations