Skip to content

Commit

Permalink
[api] Permite solicitar lista de filtros a serem processados pelo Solr.
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusandrade committed May 25, 2021
1 parent 633f772 commit d225c2c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bireme/api/bibliographic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 != '':
Expand All @@ -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)
Expand Down

0 comments on commit d225c2c

Please sign in to comment.