From 0412f409614b14932f69c200358a12ea2dac1736 Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 20 Sep 2023 09:47:09 -0800 Subject: [PATCH] enables collections keyword as standalone searchable param --- SearchAPI/SearchQuery.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/SearchAPI/SearchQuery.py b/SearchAPI/SearchQuery.py index 733e1a5d..1824d8b7 100644 --- a/SearchAPI/SearchQuery.py +++ b/SearchAPI/SearchQuery.py @@ -53,13 +53,16 @@ def can_use_cmr(self): def check_has_search_params(self): non_searchable_param = ['output', 'maxresults', 'pagesize', 'maturity'] - list_param_exceptions = ['collections'] + list_param_exceptions = ['collections'] # allows collections in granule/product search + params = [v.lower() for v in self.request.local_values] + is_collection_search = 'collections' in params + searchables = [ - v for v in self.request.local_values if v.lower() not in [*non_searchable_param, *list_param_exceptions] + v for v in params if v not in [*non_searchable_param, *list_param_exceptions] ] - if len(searchables) <= 0: + if len(searchables) <= 0 and not is_collection_search: raise ValueError( 'No searchable parameters specified, queries must include' ' parameters besides output= and maxresults='