Skip to content

Commit

Permalink
Merge pull request #143 from nayeawon/master
Browse files Browse the repository at this point in the history
[FIX] 자료열람 기관별 검색 키워드 누락 #142
  • Loading branch information
NaMooJoon authored Apr 11, 2023
2 parents 669ff81 + 69aa1ae commit e2ce357
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 e2ce357

Please sign in to comment.