Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Uses a terms array to query data (#902)
Browse files Browse the repository at this point in the history
Co-authored-by: sarayourfriend <[email protected]>
Co-authored-by: Olga Bulat <[email protected]>
Co-authored-by: Krystle Salazar <[email protected]>
  • Loading branch information
4 people authored Sep 20, 2022
1 parent a2711e7 commit 32189d0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions api/catalog/api/controllers/search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,15 +240,16 @@ def _apply_filter(
"""

if serializer_field in search_params.data:
filters = []
for arg in search_params.data[serializer_field].split(","):
_param = es_field or serializer_field
args = {"name_or_query": "term", _param: arg}
filters.append(Q(**args))
arguments = search_params.data.get(serializer_field)
if arguments is None:
return s
arguments = arguments.split(",")
parameter = es_field or serializer_field
query = Q("terms", **{parameter: arguments})
method = getattr(s, behaviour)
return method("bool", should=filters)
else:
return s
return method("bool", should=query)

return s


def _exclude_filtered(s: Search):
Expand Down

0 comments on commit 32189d0

Please sign in to comment.