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

Uses a terms array to query data #902

Merged
merged 3 commits into from
Sep 20, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions api/catalog/api/controllers/search_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,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)

krysal marked this conversation as resolved.
Show resolved Hide resolved
return s

krysal marked this conversation as resolved.
Show resolved Hide resolved
def _exclude_filtered(s: Search):
"""
Expand Down