refactor: omit useless facets in response

This commit is contained in:
Rainer Killinger
2021-04-27 13:01:40 +02:00
parent 24a91229f2
commit 0c43be2dbe
+2 -2
View File
@@ -63,7 +63,7 @@ export function parseAggregations(
const realField = realType[fieldName];
// this should always be true in theory...
if (isESTermsFilter(field) && isBucketAggregation(realField)) {
if (isESTermsFilter(field) && isBucketAggregation(realField) && realField.buckets.length > 0) {
facets.push({
buckets: realField.buckets.map((bucket) => {
return {
@@ -79,7 +79,7 @@ export function parseAggregations(
}
}
// the last part here means that it is a bucket aggregation
} else if (isESTermsFilter(type) && !isNestedAggregation(realType)) {
} else if (isESTermsFilter(type) && !isNestedAggregation(realType) && realType.buckets.length > 0) {
facets.push({
buckets: realType.buckets.map((bucket) => {
return {