From d225c2c867dc86b34f36ce671b46b54d64cc0bf8 Mon Sep 17 00:00:00 2001 From: Vinicius de Andrade Date: Tue, 25 May 2021 12:48:09 -0300 Subject: [PATCH] [api] Permite solicitar lista de filtros a serem processados pelo Solr. #1215 --- bireme/api/bibliographic.py | 11 +++++++++++ 1 file changed, 11 insertions(+) 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)