Skip to content

Commit 28c4d2a

Browse files
Merge branch 'main' into CAT-1382-2
2 parents be393dd + 86e65d0 commit 28c4d2a

File tree

15 files changed

+808
-219
lines changed

15 files changed

+808
-219
lines changed

CHANGELOG.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,29 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99

1010
### Added
1111

12+
- Spatial search support for collections via `bbox` parameter on `/collections` endpoint. Collections are now indexed with a `bbox_shape` field (GeoJSON polygon) derived from their spatial extent for efficient geospatial queries when created or updated. [#481](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/481)
13+
- Introduced SFEOS Tools (`sfeos_tools/`) - An installable Click-based CLI package for managing SFEOS deployments. Initial command `add-bbox-shape` adds the `bbox_shape` field to existing collections for spatial search compatibility. Install with `pip install sfeos-tools[elasticsearch]` or `pip install sfeos-tools[opensearch]`. [#481](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/481)
14+
- Moved SFEOS Tools to its own repository at [Healy-Hyperspatial/sfeos-tools](https://github.com/Healy-Hyperspatial/sfeos-tools). The CLI package is now maintained separately. [#PR_NUMBER]
1215
- CloudFerro logo to sponsors and supporters list [#485](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/485)
1316
- Latest news section to README [#485](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/485)
1417
- Added Redis caching configuration for navigation pagination support, enabling proper `prev` and `next` links in paginated responses. [#488](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/488)
1518

1619
### Changed
1720

21+
- Removed ENV_MAX_LIMIT environment variable; maximum limits are now handled by the default global limit environment variable. [#482](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/482)
22+
- Changed the default and maximum pagination limits for collections/items endpoints. [#482](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/482)
23+
1824
### Fixed
1925

20-
[v6.5.1] - 2025-09-30
26+
## [v6.5.1] - 2025-09-30
2127

2228
### Fixed
2329

2430
- Issue where token, query param was not being passed to POST collections search logic [#483](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/483)
2531
- Issue where datetime param was not being passed from POST collections search logic to Elasticsearch [#483](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/483)
2632
- Collections search tests to ensure both GET /collections and GET/POST /collections-search endpoints are tested [#483](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/483)
2733

28-
[v6.5.0] - 2025-09-29
34+
## [v6.5.0] - 2025-09-29
2935

3036
### Added
3137

README.md

Lines changed: 91 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,20 @@ The following organizations have contributed time and/or funding to support the
3030

3131
## Latest News
3232

33-
<div style="max-height: 200px; overflow-y: auto; padding: 10px; border: 1px solid #eaecef; border-radius: 6px; margin-bottom: 16px;">
33+
- **10/15/2025:** 🚀 SFEOS Tools v0.1.0 Released! - The new `sfeos-tools` CLI is now available on [PyPI](https://pypi.org/project/sfeos-tools/)
34+
- **10/15/2025:** Added `reindex` command to **[SFEOS-tools](https://github.com/Healy-Hyperspatial/sfeos-tools)** for zero-downtime index updates when changing mappings or settings. The new `reindex` command makes it easy to apply mapping changes, update index settings, or migrate to new index structures without any service interruption, ensuring high availability of your STAC API during maintenance operations.
35+
- **10/12/2025:** Collections search **bbox** functionality added! The collections search extension now supports bbox queries. Collections will need to be updated via the API or with the new **[SFEOS-tools](https://github.com/Healy-Hyperspatial/sfeos-tools)** CLI package to support geospatial discoverability. 🙏 Thanks again to **CloudFerro** for their sponsorship of this work!
36+
- **10/04/2025:** The **[CloudFerro](https://cloudferro.com/)** logo has been added to the sponsors and supporters list above. Their sponsorship of the ongoing collections search extension work has been invaluable. This is in addition to the many other important changes and updates their developers have added to the project.
3437

35-
- 10/04/2025: The [CloudFerro](https://cloudferro.com/) logo has been added to the sponsors and supporters list above. Their sponsorship of the ongoing collections search extension work has been invaluable. This is in addition to the many other important changes and updates their developers have added to the project.
38+
<details style="border: 1px solid #eaecef; border-radius: 6px; padding: 10px; margin-bottom: 16px; background-color: #f9f9f9;">
39+
<summary style="cursor: pointer; font-weight: bold; margin: -10px -10px 0; padding: 10px; background-color: #f0f0f0; border-bottom: 1px solid #eaecef; border-top-left-radius: 6px; border-top-right-radius: 6px;">View Older News (Click to Expand)</summary>
40+
41+
-------------
42+
- **09/25/2025:** v6.5.0 adds a new GET/POST /collections-search endpoint (disabled by default via ENABLE_COLLECTIONS_SEARCH_ROUTE) to avoid conflicts with the Transactions Extension, and enhances collections search with structured filtering (CQL2 JSON/text), query, and datetime filtering. These changes make collection discovery more powerful and configurable while preserving compatibility with transaction-enabled deployments.
43+
<!-- Add more older news items here in Markdown format; GitHub will parse them thanks to the blank line implicit in this structure -->
44+
45+
</details>
3646

37-
</div>
3847

3948
## Project Introduction - What is SFEOS?
4049

@@ -105,6 +114,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
105114
- [Interacting with the API](#interacting-with-the-api)
106115
- [Configure the API](#configure-the-api)
107116
- [Collection Pagination](#collection-pagination)
117+
- [SFEOS Tools CLI](#sfeos-tools-cli)
108118
- [Ingesting Sample Data CLI Tool](#ingesting-sample-data-cli-tool)
109119
- [Elasticsearch Mappings](#elasticsearch-mappings)
110120
- [Managing Elasticsearch Indices](#managing-elasticsearch-indices)
@@ -160,9 +170,21 @@ These endpoints support advanced collection discovery features including:
160170
- Collections are matched if their temporal extent overlaps with the provided datetime parameter
161171
- This allows for efficient discovery of collections based on time periods
162172

173+
- **Spatial Filtering**: Filter collections by their spatial extent using the `bbox` parameter
174+
- Example: `/collections?bbox=-10,35,40,70` (finds collections whose spatial extent intersects with this bounding box)
175+
- Example: `/collections?bbox=-180,-90,180,90` (finds all collections with global coverage)
176+
- Supports both 2D bounding boxes `[minx, miny, maxx, maxy]` and 3D bounding boxes `[minx, miny, minz, maxx, maxy, maxz]` (altitude values are ignored for spatial queries)
177+
- Collections are matched if their spatial extent (stored in the `extent.spatial.bbox` field) intersects with the provided bbox parameter
178+
- **Implementation Note**: When collections are created or updated, a `bbox_shape` field is automatically generated from the collection's spatial extent and indexed as a GeoJSON polygon for efficient geospatial queries
179+
- **Migrating Legacy Collections**: Collections created before this feature was added will not be discoverable via bbox search until they have the `bbox_shape` field added. You can either:
180+
- Update each collection via the API (PUT `/collections/{collection_id}` with the existing collection data)
181+
- Use the [SFEOS Tools CLI](https://github.com/Healy-Hyperspatial/sfeos-tools) (install with `pip install sfeos-tools[elasticsearch]` or `pip install sfeos-tools[opensearch]`):
182+
- `sfeos-tools add-bbox-shape --backend elasticsearch --no-ssl`
183+
- `sfeos-tools add-bbox-shape --backend opensearch --host db.example.com --no-ssl`
184+
163185
These extensions make it easier to build user interfaces that display and navigate through collections efficiently.
164186

165-
> **Configuration**: Collection search extensions (sorting, field selection, free text search, structured filtering, and datetime filtering) for the `/collections` endpoint can be disabled by setting the `ENABLE_COLLECTIONS_SEARCH` environment variable to `false`. By default, these extensions are enabled.
187+
> **Configuration**: Collection search extensions (sorting, field selection, free text search, structured filtering, datetime filtering, and spatial filtering) for the `/collections` endpoint can be disabled by setting the `ENABLE_COLLECTIONS_SEARCH` environment variable to `false`. By default, these extensions are enabled.
166188
>
167189
> **Configuration**: The custom `/collections-search` endpoint can be enabled by setting the `ENABLE_COLLECTIONS_SEARCH_ROUTE` environment variable to `true`. By default, this endpoint is **disabled**.
168190
@@ -309,9 +331,11 @@ You can customize additional settings in your `.env` file:
309331
| `ENABLE_COLLECTIONS_SEARCH` | Enable collection search extensions (sort, fields, free text search, structured filtering, and datetime filtering) on the core `/collections` endpoint. | `true` | Optional |
310332
| `ENABLE_COLLECTIONS_SEARCH_ROUTE` | Enable the custom `/collections-search` endpoint (both GET and POST methods). When disabled, the custom endpoint will not be available, but collection search extensions will still be available on the core `/collections` endpoint if `ENABLE_COLLECTIONS_SEARCH` is true. | `false` | Optional |
311333
| `ENABLE_TRANSACTIONS_EXTENSIONS` | Enables or disables the Transactions and Bulk Transactions API extensions. This is useful for deployments where mutating the catalog via the API should be prevented. If set to `true`, the POST `/collections` route for search will be unavailable in the API. | `true` | Optional |
312-
| `STAC_ITEM_LIMIT` | Sets the environment variable for result limiting to SFEOS for the number of returned items and STAC collections. | `10` | Optional |
334+
| `STAC_GLOBAL_COLLECTION_MAX_LIMIT` | Configures the maximum number of STAC collections that can be returned in a single search request. | N/A | Optional |
335+
| `STAC_DEFAULT_COLLECTION_LIMIT` | Configures the default number of STAC collections returned when no limit parameter is specified in the request. | `300` | Optional |
336+
| `STAC_GLOBAL_ITEM_MAX_LIMIT` | Configures the maximum number of STAC items that can be returned in a single search request. | N/A | Optional |
337+
| `STAC_DEFAULT_ITEM_LIMIT` | Configures the default number of STAC items returned when no limit parameter is specified in the request. | `10` | Optional |
313338
| `STAC_INDEX_ASSETS` | Controls if Assets are indexed when added to Elasticsearch/Opensearch. This allows asset fields to be included in search queries. | `false` | Optional |
314-
| `ENV_MAX_LIMIT` | Configures the environment variable in SFEOS to override the default `MAX_LIMIT`, which controls the limit parameter for returned items and STAC collections. | `10,000` | Optional |
315339
| `USE_DATETIME` | Configures the datetime search behavior in SFEOS. When enabled, searches both datetime field and falls back to start_datetime/end_datetime range for items with null datetime. When disabled, searches only by start_datetime/end_datetime range. | `true` | Optional |
316340

317341
> [!NOTE]
@@ -495,6 +519,67 @@ The system uses a precise naming convention:
495519
curl -X "GET" "http://localhost:8080/collections?limit=1&token=example_token"
496520
```
497521

522+
## SFEOS Tools CLI
523+
524+
- **Overview**: [SFEOS Tools](https://github.com/Healy-Hyperspatial/sfeos-tools) is an installable CLI package for managing and maintaining SFEOS deployments. This CLI package provides utilities for managing and maintaining SFEOS deployments.
525+
526+
- **Installation**:
527+
```shell
528+
# For Elasticsearch (from PyPI)
529+
pip install sfeos-tools[elasticsearch]
530+
531+
# For OpenSearch (from PyPI)
532+
pip install sfeos-tools[opensearch]
533+
534+
```
535+
536+
- **Available Commands**:
537+
- `add-bbox-shape`: Add bbox_shape field to existing collections for spatial search support
538+
- `reindex`: Reindex all STAC indices (collections and per-collection items) to new versioned indices and update aliases; supports both Elasticsearch and OpenSearch backends. Use this when you need to apply mapping changes, update index settings, or migrate to a new index structure. The command handles the entire process including creating new indices, reindexing data, and atomically updating aliases with zero downtime.
539+
540+
- **Basic Usage**:
541+
```shell
542+
sfeos-tools add-bbox-shape --backend elasticsearch
543+
sfeos-tools add-bbox-shape --backend opensearch
544+
```
545+
546+
- **Connection Options**: Configure database connection via CLI flags or environment variables:
547+
- `--host`: Database host (default: `localhost` or `ES_HOST` env var)
548+
- `--port`: Database port (default: `9200` or `ES_PORT` env var)
549+
- `--use-ssl` / `--no-ssl`: Use SSL connection (default: `true` or `ES_USE_SSL` env var)
550+
- `--user`: Database username (default: `ES_USER` env var)
551+
- `--password`: Database password (default: `ES_PASS` env var)
552+
553+
- **Examples**:
554+
```shell
555+
# Local Docker Compose (no SSL)
556+
sfeos-tools add-bbox-shape --backend elasticsearch --no-ssl
557+
558+
# Remote server with SSL
559+
sfeos-tools add-bbox-shape \
560+
--backend elasticsearch \
561+
--host db.example.com \
562+
--port 9200 \
563+
--user admin \
564+
--password secret
565+
566+
# Cloud deployment with environment variables
567+
ES_HOST=my-es-cluster.cloud.com ES_PORT=9243 ES_USER=elastic ES_PASS=changeme \
568+
sfeos-tools add-bbox-shape --backend elasticsearch
569+
570+
# Using --help for more information
571+
sfeos-tools --help
572+
sfeos-tools add-bbox-shape --help
573+
sfeos-tools reindex --help
574+
575+
```
576+
577+
- **Documentation**:
578+
For complete documentation, examples, and advanced usage, please visit the [SFEOS Tools GitHub repository](https://github.com/Healy-Hyperspatial/sfeos-tools).
579+
580+
- **Contributing**:
581+
Contributions, bug reports, and feature requests are welcome! Please file them on the [SFEOS Tools issue tracker](https://github.com/Healy-Hyperspatial/sfeos-tools/issues).
582+
498583
## Ingesting Sample Data CLI Tool
499584

500585
- **Overview**: The `data_loader.py` script provides a convenient way to load STAC items into the database.

stac_fastapi/core/stac_fastapi/core/base_database_logic.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import abc
44
from typing import Any, Dict, Iterable, List, Optional, Tuple
55

6+
from stac_pydantic.shared import BBox
7+
68

79
class BaseDatabaseLogic(abc.ABC):
810
"""
@@ -19,17 +21,27 @@ async def get_all_collections(
1921
limit: int,
2022
request: Any = None,
2123
sort: Optional[List[Dict[str, Any]]] = None,
22-
) -> Tuple[List[Dict[str, Any]], Optional[str]]:
24+
bbox: Optional[BBox] = None,
25+
q: Optional[List[str]] = None,
26+
filter: Optional[Dict[str, Any]] = None,
27+
query: Optional[Dict[str, Dict[str, Any]]] = None,
28+
datetime: Optional[str] = None,
29+
) -> Tuple[List[Dict[str, Any]], Optional[str], Optional[int]]:
2330
"""Retrieve a list of collections from the database, supporting pagination.
2431
2532
Args:
2633
token (Optional[str]): The pagination token.
2734
limit (int): The number of results to return.
2835
request (Any, optional): The FastAPI request object. Defaults to None.
2936
sort (Optional[List[Dict[str, Any]]], optional): Optional sort parameter. Defaults to None.
37+
bbox (Optional[BBox], optional): Bounding box to filter collections by spatial extent. Defaults to None.
38+
q (Optional[List[str]], optional): Free text search terms. Defaults to None.
39+
filter (Optional[Dict[str, Any]], optional): Structured query in CQL2 format. Defaults to None.
40+
query (Optional[Dict[str, Dict[str, Any]]], optional): Query extension parameters. Defaults to None.
41+
datetime (Optional[str], optional): Temporal filter. Defaults to None.
3042
3143
Returns:
32-
A tuple of (collections, next pagination token if any).
44+
A tuple of (collections, next pagination token if any, optional count).
3345
"""
3446
pass
3547

0 commit comments

Comments
 (0)