From 7d7b2dcf3fbbc2ebe5e733cb325f61f201acd8be Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 27 Oct 2021 13:26:03 -0400 Subject: [PATCH] LP1844418 ES rebasing Signed-off-by: Bill Erickson --- .../eg2/src/app/share/catalog/elastic.service.ts | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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; + } } -- 2.11.0