Skip to content

Commit

Permalink
use OR boolean operator for WHERE filters in text operator #259
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Bozhinov committed Nov 26, 2021
1 parent a590514 commit 865bf97
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,19 @@ def get_where_filter(filter_input, entity_name):
}

try:
or_conditional_filters = []
field_names = text_operator_fields[entity_name]
for field_name in field_names:
where_filter = {
"filter": {"where": {field_name: filter_input["text"]}},
}
where_filters.extend(
SearchAPIQueryFilterFactory.get_query_filter(
where_filter, entity_name,
),
)
or_conditional_filters.append({field_name: filter_input["text"]})

where_filter = {
"filter": {"where": {"or": or_conditional_filters}},
}
where_filters.extend(
SearchAPIQueryFilterFactory.get_query_filter(
where_filter, entity_name,
),
)
except KeyError:
# Do not raise FilterError nor attempt to create filters. Simply
# ignore text operator queries on fields that are not part of the
Expand Down

0 comments on commit 865bf97

Please sign in to comment.