Skip to content

Commit

Permalink
refactor: refactor logic for creating SearchAPIScoringFilter #398
Browse files Browse the repository at this point in the history
  • Loading branch information
VKTB committed Feb 10, 2023
1 parent 9277dd3 commit 505802a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion datagateway_api/src/search_api/query_filter_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


from datagateway_api.src.common.base_query_filter_factory import QueryFilterFactory
from datagateway_api.src.common.config import Config
from datagateway_api.src.common.exceptions import FilterError, SearchAPIError
from datagateway_api.src.search_api.filters import (
SearchAPIIncludeFilter,
Expand Down Expand Up @@ -63,7 +64,15 @@ def get_query_filter(request_filter, entity_name=None, related_entity_name=None)
elif filter_name == "skip":
log.info("skip JSON object found")
query_filters.append(SearchAPISkipFilter(filter_input))
elif filter_name == "query":
elif (
filter_name == "query"
and entity_name == "Document"
and Config.config.search_api.search_scoring.enabled
):
# We are only supporting scoring on the Document entity/ endpoint
# so the query filter is not accepted on other entities/ endpoints.
# Scoring must be enabled in order for the query filter to be
# accepted.
log.info("query JSON object found")
query_filters.append(SearchAPIScoringFilter(filter_input))
else:
Expand Down

0 comments on commit 505802a

Please sign in to comment.