Skip to content

Commit 6e8d9dd

Browse files
committed
add missing q param for item search and collection-items search (relates to stac-utils#263)
1 parent d33b0f3 commit 6e8d9dd

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
### Changed
66

7+
- add missing `q` parameters for free-text search extensions on `/search`
8+
and `/collections/{collection_id}/items` endpoints
9+
- add `str` type for `q` parameter when free-text advanced search extension is employed
710
- rename `POSTGRES_HOST_READER` to `PGHOST` in config **breaking change**
811
- rename `POSTGRES_USER` to `PGUSER` in config **breaking change**
912
- rename `POSTGRES_PASS` to `PGPASSWORD` in config **breaking change**

stac_fastapi/pgstac/core.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def all_collections( # noqa: C901
5454
sortby: Optional[str] = None,
5555
filter_expr: Optional[str] = None,
5656
filter_lang: Optional[str] = None,
57-
q: Optional[List[str]] = None,
57+
q: Optional[List[str] | str] = None,
5858
**kwargs,
5959
) -> Collections:
6060
"""Cross catalog search (GET).
@@ -359,6 +359,7 @@ async def item_collection(
359359
filter_expr: Optional[str] = None,
360360
filter_lang: Optional[str] = None,
361361
token: Optional[str] = None,
362+
q: Optional[List[str] | str] = None,
362363
**kwargs,
363364
) -> ItemCollection:
364365
"""Get all items from a specific collection.
@@ -391,6 +392,7 @@ async def item_collection(
391392
filter_lang=filter_lang,
392393
fields=fields,
393394
sortby=sortby,
395+
q=q,
394396
)
395397

396398
try:
@@ -489,6 +491,7 @@ async def get_search(
489491
filter_expr: Optional[str] = None,
490492
filter_lang: Optional[str] = None,
491493
token: Optional[str] = None,
494+
q: Optional[List[str] | str] = None,
492495
**kwargs,
493496
) -> ItemCollection:
494497
"""Cross catalog search (GET).
@@ -516,6 +519,7 @@ async def get_search(
516519
sortby=sortby,
517520
filter_query=filter_expr,
518521
filter_lang=filter_lang,
522+
q=q,
519523
)
520524

521525
try:
@@ -550,7 +554,7 @@ def _clean_search_args( # noqa: C901
550554
sortby: Optional[str] = None,
551555
filter_query: Optional[str] = None,
552556
filter_lang: Optional[str] = None,
553-
q: Optional[List[str]] = None,
557+
q: Optional[List[str] | str] = None,
554558
) -> Dict[str, Any]:
555559
"""Clean up search arguments to match format expected by pgstac"""
556560
if filter_query:
@@ -595,7 +599,9 @@ def _clean_search_args( # noqa: C901
595599

596600
base_args["fields"] = {"include": includes, "exclude": excludes}
597601

598-
if q:
602+
# free-text search basic list[str] vs advanced str
603+
# it is up to advanced to form the string properly
604+
if isinstance(q, list):
599605
base_args["q"] = " OR ".join(q)
600606

601607
# Remove None values from dict

0 commit comments

Comments
 (0)