Skip to content

Commit

Permalink
[FIX] 자료열람 기관별 검색 키워드 누락 KUBIC-HGU#142
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeawon committed Mar 22, 2023
1 parent d34c23c commit 69aa1ae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -718,19 +718,35 @@ 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<any> {
async getInstitutions(numInstit?: number): Promise<any> {
return await this.client.search({
index: this.ipSvc.ES_INDEX,
body: {
size: 0,
aggs: {
count: { terms: {
field: "published_institution.keyword",
size: 20
size: numInstit
} },
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down

0 comments on commit 69aa1ae

Please sign in to comment.