diff --git a/bireme/api/bibliographic.py b/bireme/api/bibliographic.py index 1937dca4..072bb5e7 100644 --- a/bireme/api/bibliographic.py +++ b/bireme/api/bibliographic.py @@ -80,6 +80,7 @@ def get_search(self, request, **kwargs): op = request.GET.get('op', 'search') id = request.GET.get('id', '') sort = request.GET.get('sort', 'publication_date desc') + facet_list = request.GET.getlist('facet.field', []) # filter result by status = -3 (Migration) OR 0 (LILACS Express) OR 1 (published) if fq != '': @@ -93,6 +94,16 @@ def get_search(self, request, **kwargs): search_params = {'site': settings.SEARCH_INDEX, 'op': op, 'output': 'site', 'lang': lang, 'q': q, 'fq': fq, 'start': start, 'count': count, 'id': id, 'sort': sort} + if facet_list: + search_params['facet.field'] = [] + for facet_field in facet_list: + search_params['facet.field'].append(facet_field) + facet_limit_param = 'f.{}.facet.limit'.format(facet_field) + facet_field_limit = request.GET.get(facet_limit_param, None) + if facet_field_limit: + search_params[facet_limit_param] = facet_field_limit + + r = requests.post(search_url, data=search_params) self.log_throttled_access(request)