stac-utils/pgstac

Add collection search functionality

hrodmn opened this issue · 2 comments

Collection-level search is an important tool for data discovery that can unblock users who need to know which collection(s) they are interested in before they are ready to do an item-level search.

There is a proposed collection-search extension to support this feature in the STAC API spec. It has been implemented in at least one STAC, and the result is really powerful when paired with a tool like STAC Browser: https://radiantearth.github.io/stac-browser/#/search/external/emc.spacebel.be/?.language=en

For this feature to work well in pgstac it would be important for collection extents to be properly synced with the item extents, which might not always be the case.

Perhaps related to #139, but I think this is a different feature.

in 0.8.2 we've added collection_search method

CREATE OR REPLACE FUNCTION collection_search(
_search jsonb DEFAULT '{}'::jsonb
) RETURNS jsonb AS $$
DECLARE
out_records jsonb;
number_matched bigint := collection_search_matched(_search);
number_returned bigint;
_limit int := coalesce((_search->>'limit')::float::int, 10);
_offset int := coalesce((_search->>'offset')::float::int, 0);
links jsonb := '[]';
ret jsonb;
base_url text:= concat(rtrim(base_url(_search->'conf'),'/'), '/collections');
prevoffset int;
nextoffset int;
BEGIN

https://github.com/stac-utils/pgstac/blob/main/CHANGELOG.md#v082

but this is not yet used at stac-fastapi level: stac-utils/stac-fastapi#696

Amazing, thanks for pointing that out @vincentsarago!