diff --git a/CHANGES.md b/CHANGES.md index b838437..045184d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,9 @@ ### Changed +- add missing `q` parameters for free-text search extensions on `/search` + and `/collections/{collection_id}/items` endpoints +- add `str` type for `q` parameter when free-text advanced search extension is employed - rename `POSTGRES_HOST_READER` to `PGHOST` in config **breaking change** - rename `POSTGRES_USER` to `PGUSER` in config **breaking change** - rename `POSTGRES_PASS` to `PGPASSWORD` in config **breaking change** diff --git a/stac_fastapi/pgstac/core.py b/stac_fastapi/pgstac/core.py index 7854ad0..3dbf25a 100644 --- a/stac_fastapi/pgstac/core.py +++ b/stac_fastapi/pgstac/core.py @@ -54,7 +54,7 @@ async def all_collections( # noqa: C901 sortby: Optional[str] = None, filter_expr: Optional[str] = None, filter_lang: Optional[str] = None, - q: Optional[List[str]] = None, + q: Optional[Union[List[str], str]] = None, **kwargs, ) -> Collections: """Cross catalog search (GET). @@ -359,6 +359,7 @@ async def item_collection( filter_expr: Optional[str] = None, filter_lang: Optional[str] = None, token: Optional[str] = None, + q: Optional[Union[List[str], str]] = None, **kwargs, ) -> ItemCollection: """Get all items from a specific collection. @@ -391,6 +392,7 @@ async def item_collection( filter_lang=filter_lang, fields=fields, sortby=sortby, + q=q, ) try: @@ -489,6 +491,7 @@ async def get_search( filter_expr: Optional[str] = None, filter_lang: Optional[str] = None, token: Optional[str] = None, + q: Optional[Union[List[str], str]] = None, **kwargs, ) -> ItemCollection: """Cross catalog search (GET). @@ -516,6 +519,7 @@ async def get_search( sortby=sortby, filter_query=filter_expr, filter_lang=filter_lang, + q=q, ) try: @@ -550,7 +554,7 @@ def _clean_search_args( # noqa: C901 sortby: Optional[str] = None, filter_query: Optional[str] = None, filter_lang: Optional[str] = None, - q: Optional[List[str]] = None, + q: Optional[Union[List[str], str]] = None, ) -> Dict[str, Any]: """Clean up search arguments to match format expected by pgstac""" if filter_query: @@ -595,8 +599,12 @@ def _clean_search_args( # noqa: C901 base_args["fields"] = {"include": includes, "exclude": excludes} - if q: + # free-text search basic list[str] vs advanced str + # it is up to advanced to form the string properly + if isinstance(q, list): base_args["q"] = " OR ".join(q) + elif q: + base_args["q"] = q # Remove None values from dict clean = {}