Skip to content

Commit dbb1831

Browse files
Merge branch 'main' into CAT-1413-2
2 parents e15494a + 1d24a7b commit dbb1831

File tree

28 files changed

+714
-170
lines changed

28 files changed

+714
-170
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repos:
1616
# E501 let black handle all line length decisions
1717
# W503 black conflicts with "line break before operator" rule
1818
# E203 black conflicts with "whitespace before ':'" rule
19-
'--ignore=E501,W503,E203,C901,E231' ]
19+
'--ignore=E501,W503,E203,C901,E231,E702' ]
2020
- repo: https://github.com/pre-commit/mirrors-mypy
2121
rev: v0.991
2222
hooks:

CHANGELOG.md

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

99
## [Unreleased]
1010

11+
## [v6.3.0] - 2025-09-16
12+
1113
### Added
1214

15+
- `STAC_INDEX_ASSETS` environment variable to allow asset serialization to be configurable. [#433](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/433)
1316
- Added the `ENV_MAX_LIMIT` environment variable to SFEOS, allowing overriding of the `MAX_LIMIT`, which controls the `?limit` parameter for returned items and STAC collections. [#434](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/434)
1417
- Updated the `format_datetime_range` function to support milliseconds. [#423](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/423)
1518
- Added `USE_DATETIME` environment variable behavior to set datetime filtering logic. [#443](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/443)
19+
- Sort, Query, and Filter extension and functionality to the item collection route. [#437](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/437)
20+
- Added Fields Extension implementation for the `/collections/{collection_id}/items` endpoint. [#436](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/436)
1621

1722
### Changed
1823

19-
- Changed assets serialization to prevent mapping explosion while allowing asset inforamtion to be indexed. [#341](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/341)
24+
- Changed assets serialization to prevent mapping explosion while allowing asset information to be indexed. [#341](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/341)
25+
- Simplified the item_collection function in core.py, moving the request to the get_search function. [#437](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/437)
26+
- Updated the `format_datetime_range` function to support milliseconds. [#423](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/423)
27+
- Blocked the /collections/{collection_id}/bulk_items endpoint when environmental variable ENABLE_DATETIME_INDEX_FILTERING is set to true. [#438](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/438)
2028

2129
### Fixed
2230

31+
- Fixed issue where sortby was not accepting the default sort, where a + or - was not specified before the field value ie. localhost:8081/collections/{collection_id}/items?sortby=id. [#437](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/437)
32+
2333
## [v6.2.1] - 2025-09-02
2434

2535
### Added
@@ -496,7 +506,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
496506
- Use genexp in execute_search and get_all_collections to return results.
497507
- Added db_to_stac serializer to item_collection method in core.py.
498508

499-
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.2.1...main
509+
[Unreleased]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.3.0...main
510+
[v6.3.0]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.2.1...v6.3.0
500511
[v6.2.1]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.2.0...v6.2.1
501512
[v6.2.0]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.1.0...v6.2.0
502513
[v6.1.0]: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/compare/v6.0.0...v6.1.0

README.md

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,43 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
6666

6767
## Table of Contents
6868

69-
- [Documentation & Resources](#documentation--resources)
70-
- [Package Structure](#package-structure)
71-
- [Examples](#examples)
72-
- [Performance](#performance)
73-
- [Quick Start](#quick-start)
74-
- [Installation](#installation)
75-
- [Running Locally](#running-locally)
76-
- [Configuration reference](#configuration-reference)
77-
- [Interacting with the API](#interacting-with-the-api)
78-
- [Configure the API](#configure-the-api)
79-
- [Collection pagination](#collection-pagination)
80-
- [Ingesting Sample Data CLI Tool](#ingesting-sample-data-cli-tool)
81-
- [Elasticsearch Mappings](#elasticsearch-mappings)
82-
- [Managing Elasticsearch Indices](#managing-elasticsearch-indices)
83-
- [Snapshots](#snapshots)
84-
- [Reindexing](#reindexing)
85-
- [Auth](#auth)
86-
- [Aggregation](#aggregation)
87-
- [Rate Limiting](#rate-limiting)
88-
- [Datetime-Based Index Management](#datetime-based-index-management)
69+
- [stac-fastapi-elasticsearch-opensearch](#stac-fastapi-elasticsearch-opensearch)
70+
- [Sponsors \& Supporters](#sponsors--supporters)
71+
- [Project Introduction - What is SFEOS?](#project-introduction---what-is-sfeos)
72+
- [Common Deployment Patterns](#common-deployment-patterns)
73+
- [Technologies](#technologies)
74+
- [Table of Contents](#table-of-contents)
75+
- [Documentation \& Resources](#documentation--resources)
76+
- [Package Structure](#package-structure)
77+
- [Examples](#examples)
78+
- [Performance](#performance)
79+
- [Direct Response Mode](#direct-response-mode)
80+
- [Quick Start](#quick-start)
81+
- [Installation](#installation)
82+
- [Running Locally](#running-locally)
83+
- [Using Pre-built Docker Images](#using-pre-built-docker-images)
84+
- [Using Docker Compose](#using-docker-compose)
85+
- [Configuration Reference](#configuration-reference)
86+
- [Datetime-Based Index Management](#datetime-based-index-management)
87+
- [Overview](#overview)
88+
- [When to Use](#when-to-use)
89+
- [Configuration](#configuration)
90+
- [Enabling Datetime-Based Indexing](#enabling-datetime-based-indexing)
91+
- [Related Configuration Variables](#related-configuration-variables)
92+
- [How Datetime-Based Indexing Works](#how-datetime-based-indexing-works)
93+
- [Index and Alias Naming Convention](#index-and-alias-naming-convention)
94+
- [Index Size Management](#index-size-management)
95+
- [Interacting with the API](#interacting-with-the-api)
96+
- [Configure the API](#configure-the-api)
97+
- [Collection Pagination](#collection-pagination)
98+
- [Ingesting Sample Data CLI Tool](#ingesting-sample-data-cli-tool)
99+
- [Elasticsearch Mappings](#elasticsearch-mappings)
100+
- [Managing Elasticsearch Indices](#managing-elasticsearch-indices)
101+
- [Snapshots](#snapshots)
102+
- [Reindexing](#reindexing)
103+
- [Auth](#auth)
104+
- [Aggregation](#aggregation)
105+
- [Rate Limiting](#rate-limiting)
89106

90107
## Documentation & Resources
91108

@@ -228,6 +245,7 @@ You can customize additional settings in your `.env` file:
228245
| `DATABASE_REFRESH` | Controls whether database operations refresh the index immediately after changes. If set to `true`, changes will be immediately searchable. If set to `false`, changes may not be immediately visible but can improve performance for bulk operations. If set to `wait_for`, changes will wait for the next refresh cycle to become visible. | `false` | Optional |
229246
| `ENABLE_TRANSACTIONS_EXTENSIONS` | Enables or disables the Transactions and Bulk Transactions API extensions. If set to `false`, the POST `/collections` route and related transaction endpoints (including bulk transaction operations) will be unavailable in the API. This is useful for deployments where mutating the catalog via the API should be prevented. | `true` | Optional |
230247
| `STAC_ITEM_LIMIT` | Sets the environment variable for result limiting to SFEOS for the number of returned items and STAC collections. | `10` | Optional |
248+
| `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 |
231249
| `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 |
232250
| `USE_DATETIME` | Configures the environment variable to control datetime filtering behavior. When `true`, searches by datetime field, and if datetime is `null` then by start/end datetime fields. When `false`, always searches only by start/end datetime fields. | true | Optional |
233251

compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
environment:
1010
- STAC_FASTAPI_TITLE=stac-fastapi-elasticsearch
1111
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Elasticsearch backend
12-
- STAC_FASTAPI_VERSION=6.2.1
12+
- STAC_FASTAPI_VERSION=6.0.0
1313
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-elasticsearch
1414
- APP_HOST=0.0.0.0
1515
- APP_PORT=8080
@@ -43,7 +43,7 @@ services:
4343
environment:
4444
- STAC_FASTAPI_TITLE=stac-fastapi-opensearch
4545
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Opensearch backend
46-
- STAC_FASTAPI_VERSION=6.2.1
46+
- STAC_FASTAPI_VERSION=6.0.0
4747
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-opensearch
4848
- APP_HOST=0.0.0.0
4949
- APP_PORT=8082

dockerfiles/Dockerfile.dev.os

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ FROM python:3.10-slim
44
# update apt pkgs, and install build-essential for ciso8601
55
RUN apt-get update && \
66
apt-get -y upgrade && \
7-
apt-get -y install build-essential && \
7+
apt-get -y install build-essential git && \
88
apt-get clean && \
99
rm -rf /var/lib/apt/lists/*
1010

11-
RUN apt-get -y install git
1211
# update certs used by Requests
1312
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
1413

examples/auth/compose.basic_auth.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
environment:
1010
- STAC_FASTAPI_TITLE=stac-fastapi-elasticsearch
1111
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Elasticsearch backend
12-
- STAC_FASTAPI_VERSION=6.2.1
12+
- STAC_FASTAPI_VERSION=6.0.0
1313
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-elasticsearch
1414
- APP_HOST=0.0.0.0
1515
- APP_PORT=8080
@@ -43,7 +43,7 @@ services:
4343
environment:
4444
- STAC_FASTAPI_TITLE=stac-fastapi-opensearch
4545
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Opensearch backend
46-
- STAC_FASTAPI_VERSION=6.2.1
46+
- STAC_FASTAPI_VERSION=6.0.0
4747
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-opensearch
4848
- APP_HOST=0.0.0.0
4949
- APP_PORT=8082

examples/auth/compose.oauth2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
environment:
1010
- STAC_FASTAPI_TITLE=stac-fastapi-elasticsearch
1111
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Elasticsearch backend
12-
- STAC_FASTAPI_VERSION=6.2.1
12+
- STAC_FASTAPI_VERSION=6.0.0
1313
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-elasticsearch
1414
- APP_HOST=0.0.0.0
1515
- APP_PORT=8080
@@ -44,7 +44,7 @@ services:
4444
environment:
4545
- STAC_FASTAPI_TITLE=stac-fastapi-opensearch
4646
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Opensearch backend
47-
- STAC_FASTAPI_VERSION=6.2.1
47+
- STAC_FASTAPI_VERSION=6.0.0
4848
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-opensearch
4949
- APP_HOST=0.0.0.0
5050
- APP_PORT=8082

examples/auth/compose.route_dependencies.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
environment:
1010
- STAC_FASTAPI_TITLE=stac-fastapi-elasticsearch
1111
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Elasticsearch backend
12-
- STAC_FASTAPI_VERSION=6.2.1
12+
- STAC_FASTAPI_VERSION=6.0.0
1313
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-elasticsearch
1414
- APP_HOST=0.0.0.0
1515
- APP_PORT=8080
@@ -43,7 +43,7 @@ services:
4343
environment:
4444
- STAC_FASTAPI_TITLE=stac-fastapi-opensearch
4545
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Opensearch backend
46-
- STAC_FASTAPI_VERSION=6.2.1
46+
- STAC_FASTAPI_VERSION=6.0.0
4747
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-opensearch
4848
- APP_HOST=0.0.0.0
4949
- APP_PORT=8082

examples/rate_limit/compose.rate_limit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
environment:
1010
- STAC_FASTAPI_TITLE=stac-fastapi-elasticsearch
1111
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Elasticsearch backend
12-
- STAC_FASTAPI_VERSION=6.2.1
12+
- STAC_FASTAPI_VERSION=6.0.0
1313
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-elasticsearch
1414
- APP_HOST=0.0.0.0
1515
- APP_PORT=8080
@@ -43,7 +43,7 @@ services:
4343
environment:
4444
- STAC_FASTAPI_TITLE=stac-fastapi-opensearch
4545
- STAC_FASTAPI_DESCRIPTION=A STAC FastAPI with an Opensearch backend
46-
- STAC_FASTAPI_VERSION=6.2.1
46+
- STAC_FASTAPI_VERSION=6.0.0
4747
- STAC_FASTAPI_LANDING_PAGE_ID=stac-fastapi-opensearch
4848
- APP_HOST=0.0.0.0
4949
- APP_PORT=8082

scripts/reindex_elasticsearch.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import asyncio
2+
import time
3+
4+
from stac_fastapi.elasticsearch.config import AsyncElasticsearchSettings
5+
from stac_fastapi.elasticsearch.database_logic import create_index_templates
6+
from stac_fastapi.sfeos_helpers.mappings import COLLECTIONS_INDEX, ITEMS_INDEX_PREFIX
7+
8+
9+
async def reindex(client, index, new_index, aliases):
10+
"""Reindex STAC index"""
11+
print(f"reindexing {index} to {new_index}")
12+
13+
await client.options(ignore_status=400).indices.create(index=new_index)
14+
15+
reindex_resp = await client.reindex(
16+
dest={"index": new_index},
17+
source={"index": [index]},
18+
wait_for_completion=False,
19+
script={
20+
"source": "if (ctx._source.containsKey('assets')){List l = new ArrayList();for (key in ctx._source.assets.keySet()) {def item = ctx._source.assets[key]; item['es_key'] = key; l.add(item)}ctx._source.assets=l} if (ctx._source.containsKey('item_assets')){ List a = new ArrayList(); for (key in ctx._source.item_assets.keySet()) {def item = ctx._source.item_assets[key]; item['es_key'] = key; a.add(item)}ctx._source.item_assets=a}",
21+
"lang": "painless",
22+
},
23+
)
24+
25+
task_id = reindex_resp["task"]
26+
27+
reindex_complete = False
28+
while not reindex_complete:
29+
task_resp = await client.tasks.get(task_id=task_id)
30+
31+
if "completed" in task_resp and task_resp["completed"]:
32+
reindex_complete = True
33+
34+
elif "error" in task_resp:
35+
reindex_complete = True
36+
print(f"Reindex failed for {index} with error: {task_resp['error']}")
37+
38+
else:
39+
time.sleep(60)
40+
41+
actions = []
42+
for alias in aliases["aliases"]:
43+
actions.extend(
44+
[
45+
{"add": {"index": new_index, "alias": alias}},
46+
{"remove": {"index": index, "alias": alias}},
47+
]
48+
)
49+
50+
await client.indices.update_aliases(actions=actions)
51+
52+
53+
async def run():
54+
"""Reindex all STAC indexes for mapping update"""
55+
client = AsyncElasticsearchSettings().create_client
56+
57+
await create_index_templates()
58+
59+
collection_response = await client.indices.get_alias(name=COLLECTIONS_INDEX)
60+
collections = await client.search(index=COLLECTIONS_INDEX)
61+
62+
collection_index, collection_aliases = next(iter(collection_response.items()))
63+
collection_index_name, version = collection_index.rsplit("-", 1)
64+
new_collection_index = f"{collection_index_name}-{str(int(version) + 1).zfill(6)}"
65+
66+
await reindex(client, collection_index, new_collection_index, collection_aliases)
67+
68+
for collection in collections["hits"]["hits"]:
69+
70+
item_indexes = await client.indices.get_alias(
71+
name=f"{ITEMS_INDEX_PREFIX}{collection['_id']}*"
72+
)
73+
74+
for item_index, aliases in item_indexes.items():
75+
item_index_name, version = item_index.rsplit("-", 1)
76+
new_item_index = f"{item_index_name}-{str(int(version) + 1).zfill(6)}"
77+
78+
await reindex(client, item_index, new_item_index, aliases)
79+
80+
await client.close()
81+
82+
83+
if __name__ == "__main__":
84+
asyncio.run(run())

0 commit comments

Comments
 (0)