From 69aa1ae63176f77bdca62d001d958f448b68b826 Mon Sep 17 00:00:00 2001 From: nayeawon Date: Wed, 22 Mar 2023 21:11:27 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EC=9E=90=EB=A3=8C=EC=97=B4=EB=9E=8C=20?= =?UTF-8?q?=EA=B8=B0=EA=B4=80=EB=B3=84=20=EA=B2=80=EC=83=89=20=ED=82=A4?= =?UTF-8?q?=EC=9B=8C=EB=93=9C=20=EB=88=84=EB=9D=BD=20#142?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../elasticsearch.service.ts | 20 +++++++++++++++++-- .../article-library.component.ts | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/app/core/services/elasticsearch-service/elasticsearch.service.ts b/src/app/core/services/elasticsearch-service/elasticsearch.service.ts index e4f82163..d4b67fd4 100755 --- a/src/app/core/services/elasticsearch-service/elasticsearch.service.ts +++ b/src/app/core/services/elasticsearch-service/elasticsearch.service.ts @@ -718,11 +718,27 @@ export class ElasticsearchService { }); } + async getInstitutionsNum() { + return await this.client.search({ + index: this.ipSvc.ES_INDEX, + body: { + size: 0, + aggs: { + unique_institutions: { + cardinality: { + field: "published_institution.keyword", + } + }, + }, + }, + }); + } + /** * @description Send query of getting all published_institution field value and number of articles for each of the value. * @returns query response */ - async getInstitutions(): Promise { + async getInstitutions(numInstit?: number): Promise { return await this.client.search({ index: this.ipSvc.ES_INDEX, body: { @@ -730,7 +746,7 @@ export class ElasticsearchService { aggs: { count: { terms: { field: "published_institution.keyword", - size: 20 + size: numInstit } }, }, }, diff --git a/src/app/features/article-library/components/article-library-root/article-library.component.ts b/src/app/features/article-library/components/article-library-root/article-library.component.ts index 612049d3..87b449cf 100755 --- a/src/app/features/article-library/components/article-library-root/article-library.component.ts +++ b/src/app/features/article-library/components/article-library-root/article-library.component.ts @@ -91,7 +91,8 @@ export class ArticleLibraryComponent implements OnInit { */ //new async loadInstitutions() { - let res = await this.elasticsearchService.getInstitutions(); + let numInstit = await this.elasticsearchService.getInstitutionsNum(); + let res = await this.elasticsearchService.getInstitutions(numInstit['aggregations']['unique_institutions']['value']); let numRes = await this.elasticsearchService.countAllDocs(); this.institutionList = res["aggregations"]["count"]["buckets"]; this.totalSavedDocsNum = numRes["count"];