Skip to content

Commit 14a625d

Browse files
committed
filter lang
1 parent b585819 commit 14a625d

File tree

1 file changed

+15
-2
lines changed
  • stac_fastapi/core/stac_fastapi/core

1 file changed

+15
-2
lines changed

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ async def all_collections(
229229
fields: Optional[List[str]] = None,
230230
sortby: Optional[str] = None,
231231
filter_expr: Optional[str] = None,
232+
query: Optional[str] = None,
233+
filter_lang: Optional[str] = None,
232234
q: Optional[Union[str, List[str]]] = None,
233235
**kwargs,
234236
) -> stac_types.Collections:
@@ -237,7 +239,9 @@ async def all_collections(
237239
Args:
238240
fields (Optional[List[str]]): Fields to include or exclude from the results.
239241
sortby (Optional[str]): Sorting options for the results.
240-
filter_expr (Optional[str]): Structured filter in CQL2 format.
242+
filter_expr (Optional[str]): Structured filter expression in CQL2 JSON format.
243+
query (Optional[str]): Legacy query parameter (deprecated).
244+
filter_lang (Optional[str]): Must be 'cql2-json' if specified, other values will result in an error.
241245
q (Optional[Union[str, List[str]]]): Free text search terms.
242246
**kwargs: Keyword arguments from the request.
243247
@@ -285,7 +289,16 @@ async def all_collections(
285289
try:
286290
import orjson
287291

288-
parsed_filter = orjson.loads(filter_expr)
292+
# Check if filter_lang is specified and not cql2-json
293+
if filter_lang is not None and filter_lang != "cql2-json":
294+
# Raise an error for unsupported filter languages
295+
raise HTTPException(
296+
status_code=400,
297+
detail=f"Only 'cql2-json' filter language is supported for collections. Got '{filter_lang}'.",
298+
)
299+
300+
# For GET requests, we only handle cql2-json
301+
parsed_filter = orjson.loads(unquote_plus(filter_expr))
289302
except Exception as e:
290303
raise HTTPException(
291304
status_code=400, detail=f"Invalid filter parameter: {e}"

0 commit comments

Comments
 (0)