Skip to content

Commit

Permalink
split keywords by , in facet, then recalculate
Browse files Browse the repository at this point in the history
  • Loading branch information
pvgenuchten committed Jan 9, 2025
1 parent 07bd28b commit 52ad109
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pycsw/ogc/api/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,22 @@ def get_facets(self, filters=None) -> dict:
'value': fq[0],
'count': fq[1]
})

if facet in ['keywords']:
splitkws = {}
for k in facets_results[facet]['buckets']:
if 'value' in k.keys() and k['value'] not in [None,''] and int(k['count']) > 0:
if ',' in k['value']: # split kws by ,
for k2 in k['value'].split(','):
splitkws[k2.lower()] = int(k['count']) + int(splitkws.get(k2.lower(),0))
else:
splitkws[k['value'].lower()] = int(k['count']) + int(splitkws.get(k['value'].lower(),0))
facets_results[facet]['buckets'] = [] # reset facet, populate it again
for k,v in splitkws.items():
facets_results[facet]['buckets'].append({
'value': k,
'count': v
})

return facets_results

Expand Down

0 comments on commit 52ad109

Please sign in to comment.