From: Bill Erickson Date: Wed, 27 Oct 2021 17:26:03 +0000 (-0400) Subject: LP1844418 ES rebasing X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=750811210e2ac448f15da0503c8ce776401d5c3b;p=working%2FEvergreen.git LP1844418 ES rebasing Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/share/catalog/elastic.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/elastic.service.ts index 434ebddcd4..121d10b960 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/elastic.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/elastic.service.ts @@ -204,10 +204,14 @@ export class ElasticService { const marcQuery = new BoolQuery(); const tag = ms.tags[idx]; const subfield = ms.subfields[idx]; + + /* + * Un-comment this if supporting match ops for marc searches. const matchOp = ms.matchOp[idx]; this.appendMatchOp( marcQuery, matchOp, 'marc.value.text*', 'marc.value', value); + */ if (tag) { marcQuery.must(new TermQuery('marc.tag', tag)); @@ -354,5 +358,36 @@ export class ElasticService { return; } } + + formatFacets(facets: any) { + const facetData = {}; + Object.keys(facets).forEach(ebfId => { + const facetHash = facets[ebfId]; + + const ebfData = []; + Object.keys(facetHash).forEach(value => { + const count = facetHash[value]; + ebfData.push({value : value, count : count}); + }); + + const parts = ebfId.split('|'); + const fclass = parts[0]; + const fname = parts[1]; + + if (!facetData[fclass]) { facetData[fclass] = {}; } + + facetData[fclass][fname] = { + // 'cmfLabel' is what the higher-level code seeks + cmfLabel : ebfId, // TODO + valueList : ebfData.sort((a, b) => { + if (a.count > b.count) { return -1; } + if (a.count < b.count) { return 1; } + return a.value < b.value ? -1 : 1; + }) + }; + }); + + return facetData; + } }