Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

- Unified elasticsearch and opensearch reindex scripts and added functionality to the new SFEOS-tools CLI package. [#490](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/490)
- 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)
- Changed the default and maximum pagination limits for collections/items endpoints. [#482](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/482)

Expand Down
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,17 @@ The following organizations have contributed time and/or funding to support the

## Latest News

<div style="max-height: 200px; overflow-y: auto; padding: 10px; border: 1px solid #eaecef; border-radius: 6px; margin-bottom: 16px;">

- **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](#sfeos-tools-cli)** CLI package to support geospatial discoverability. Thanks again to **CloudFerro** for their sponsorship of this work!
- **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.

</div>
<details style="border: 1px solid #eaecef; border-radius: 6px; padding: 10px; margin-bottom: 16px; background-color: #f9f9f9;">
<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>

-------------
- **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. Thanks to **CloudFerro** for their sponsorship of this work!
<!-- Add more older news items here in Markdown format; GitHub will parse them thanks to the blank line implicit in this structure -->

</details>

## Project Introduction - What is SFEOS?

Expand Down Expand Up @@ -506,11 +511,17 @@ The system uses a precise naming convention:

- **Available Commands**:
- `add-bbox-shape`: Add bbox_shape field to existing collections for spatial search support
- `reindex`: Reindex all STAC indices (collections and per-collection items) to new versioned indices and update aliases; supports both Elasticsearch and OpenSearch backends

- **Basic Usage**:
```shell
# Add bbox_shape to collections
sfeos-tools add-bbox-shape --backend elasticsearch
sfeos-tools add-bbox-shape --backend opensearch

# Reindex all STAC data
sfeos-tools reindex --backend elasticsearch --yes
sfeos-tools reindex --backend opensearch --yes
```

- **Connection Options**: Configure database connection via CLI flags or environment variables:
Expand Down Expand Up @@ -540,6 +551,13 @@ The system uses a precise naming convention:
# Using --help for more information
sfeos-tools --help
sfeos-tools add-bbox-shape --help
sfeos-tools reindex --help

# Reindex with custom batch size and concurrency
sfeos-tools reindex --backend elasticsearch --batch-size 500 --concurrency 4 --yes

# Reindex with progress updates every 1000 items
sfeos-tools reindex --backend opensearch --progress 1000 --yes
```

For more details, see the [SFEOS Tools README](./sfeos_tools/README.md).
Expand Down
84 changes: 0 additions & 84 deletions scripts/reindex_elasticsearch.py

This file was deleted.

84 changes: 0 additions & 84 deletions scripts/reindex_opensearch.py

This file was deleted.

108 changes: 108 additions & 0 deletions sfeos_tools/sfeos_tools/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from stac_fastapi.sfeos_helpers.database import add_bbox_shape_to_collection
from stac_fastapi.sfeos_helpers.mappings import COLLECTIONS_INDEX

from .reindex import run as unified_reindex_run

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -225,5 +227,111 @@ def add_bbox_shape(backend, host, port, use_ssl, user, password):
sys.exit(1)


@cli.command("reindex")
@click.option(
"--backend",
type=click.Choice(["elasticsearch", "opensearch"], case_sensitive=False),
required=True,
help="Database backend to use",
)
@click.option(
"--host",
type=str,
default=None,
help="Database host (default: localhost or ES_HOST env var)",
)
@click.option(
"--port",
type=int,
default=None,
help="Database port (default: 9200 for ES, 9202 for OS, or ES_PORT env var)",
)
@click.option(
"--use-ssl/--no-ssl",
default=None,
help="Use SSL connection (default: true or ES_USE_SSL env var)",
)
@click.option(
"--user",
type=str,
default=None,
help="Database username (default: ES_USER env var)",
)
@click.option(
"--password",
type=str,
default=None,
help="Database password (default: ES_PASS env var)",
)
@click.option(
"--yes",
is_flag=True,
help="Skip confirmation prompt",
)
def reindex(backend, host, port, use_ssl, user, password, yes):
"""Reindex all STAC indexes to the next version and update aliases.

For Elasticsearch, this runs a migration that:
- Creates/updates index templates
- Reindexes collections and item indexes to a new version
- Applies asset migration script for compatibility
- Switches aliases to the new indexes
"""
import os

backend = backend.lower()

if not yes:
proceed = click.confirm(
"This will reindex all collections and item indexes and update aliases. Proceed?",
default=False,
)
if not proceed:
click.echo(click.style("Aborted", fg="yellow"))
return

# Set environment variables from CLI options if provided
if host:
os.environ["ES_HOST"] = host
if port:
os.environ["ES_PORT"] = str(port)
if use_ssl is not None:
os.environ["ES_USE_SSL"] = "true" if use_ssl else "false"
if user:
os.environ["ES_USER"] = user
if password:
os.environ["ES_PASS"] = password

try:
asyncio.run(unified_reindex_run(backend))
click.echo(
click.style(
f"✓ Reindex ({backend.title()}) completed successfully", fg="green"
)
)
except KeyboardInterrupt:
click.echo(click.style("\n✗ Reindex interrupted by user", fg="yellow"))
sys.exit(1)
except Exception as e:
error_msg = str(e)
click.echo(click.style(f"✗ Reindex failed: {error_msg}", fg="red"))
# Provide helpful hints for common errors
if "TLS" in error_msg or "SSL" in error_msg:
click.echo(
click.style(
"\n💡 Hint: If you're connecting to a local Docker Compose instance, try adding --no-ssl flag",
fg="yellow",
)
)
elif "Connection refused" in error_msg:
click.echo(
click.style(
"\n💡 Hint: Make sure your database is running and accessible at the specified host:port",
fg="yellow",
)
)
sys.exit(1)


if __name__ == "__main__":
cli()
Loading