stac-fastapi-core 6.0.0__py3-none-any.whl → 6.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stac_fastapi/core/core.py +18 -6
- stac_fastapi/core/datetime_utils.py +1 -0
- stac_fastapi/core/serializers.py +1 -0
- stac_fastapi/core/session.py +1 -0
- stac_fastapi/core/version.py +1 -1
- {stac_fastapi_core-6.0.0.dist-info → stac_fastapi_core-6.2.0.dist-info}/METADATA +91 -14
- {stac_fastapi_core-6.0.0.dist-info → stac_fastapi_core-6.2.0.dist-info}/RECORD +9 -9
- {stac_fastapi_core-6.0.0.dist-info → stac_fastapi_core-6.2.0.dist-info}/WHEEL +0 -0
- {stac_fastapi_core-6.0.0.dist-info → stac_fastapi_core-6.2.0.dist-info}/top_level.txt +0 -0
stac_fastapi/core/core.py
CHANGED
|
@@ -324,10 +324,15 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
324
324
|
search=search, collection_ids=[collection_id]
|
|
325
325
|
)
|
|
326
326
|
|
|
327
|
-
|
|
328
|
-
search = self.database.apply_datetime_filter(
|
|
329
|
-
search=search,
|
|
327
|
+
try:
|
|
328
|
+
search, datetime_search = self.database.apply_datetime_filter(
|
|
329
|
+
search=search, datetime=datetime
|
|
330
330
|
)
|
|
331
|
+
except (ValueError, TypeError) as e:
|
|
332
|
+
# Handle invalid interval formats if return_date fails
|
|
333
|
+
msg = f"Invalid interval format: {datetime}, error: {e}"
|
|
334
|
+
logger.error(msg)
|
|
335
|
+
raise HTTPException(status_code=400, detail=msg)
|
|
331
336
|
|
|
332
337
|
if bbox:
|
|
333
338
|
bbox = [float(x) for x in bbox]
|
|
@@ -342,6 +347,7 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
342
347
|
sort=None,
|
|
343
348
|
token=token,
|
|
344
349
|
collection_ids=[collection_id],
|
|
350
|
+
datetime_search=datetime_search,
|
|
345
351
|
)
|
|
346
352
|
|
|
347
353
|
items = [
|
|
@@ -500,10 +506,15 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
500
506
|
search=search, collection_ids=search_request.collections
|
|
501
507
|
)
|
|
502
508
|
|
|
503
|
-
|
|
504
|
-
search = self.database.apply_datetime_filter(
|
|
505
|
-
search=search,
|
|
509
|
+
try:
|
|
510
|
+
search, datetime_search = self.database.apply_datetime_filter(
|
|
511
|
+
search=search, datetime=search_request.datetime
|
|
506
512
|
)
|
|
513
|
+
except (ValueError, TypeError) as e:
|
|
514
|
+
# Handle invalid interval formats if return_date fails
|
|
515
|
+
msg = f"Invalid interval format: {search_request.datetime}, error: {e}"
|
|
516
|
+
logger.error(msg)
|
|
517
|
+
raise HTTPException(status_code=400, detail=msg)
|
|
507
518
|
|
|
508
519
|
if search_request.bbox:
|
|
509
520
|
bbox = search_request.bbox
|
|
@@ -560,6 +571,7 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
560
571
|
token=search_request.token,
|
|
561
572
|
sort=sort,
|
|
562
573
|
collection_ids=search_request.collections,
|
|
574
|
+
datetime_search=datetime_search,
|
|
563
575
|
)
|
|
564
576
|
|
|
565
577
|
fields = (
|
stac_fastapi/core/serializers.py
CHANGED
stac_fastapi/core/session.py
CHANGED
stac_fastapi/core/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""library version."""
|
|
2
|
-
__version__ = "6.
|
|
2
|
+
__version__ = "6.2.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stac-fastapi-core
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.2.0
|
|
4
4
|
Summary: Core library for the Elasticsearch and Opensearch stac-fastapi backends.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
|
|
6
6
|
License: MIT
|
|
@@ -46,7 +46,7 @@ Requires-Dist: slowapi~=0.1.9
|
|
|
46
46
|
[](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/network/members)
|
|
47
47
|
[](https://pypi.org/project/stac-fastapi-elasticsearch/)
|
|
48
48
|
[](https://github.com/radiantearth/stac-spec/tree/v1.1.0)
|
|
49
|
-
[](https://github.com/stac-utils/stac-fastapi)
|
|
50
50
|
|
|
51
51
|
## Sponsors & Supporters
|
|
52
52
|
|
|
@@ -116,6 +116,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
116
116
|
- [Auth](#auth)
|
|
117
117
|
- [Aggregation](#aggregation)
|
|
118
118
|
- [Rate Limiting](#rate-limiting)
|
|
119
|
+
- [Datetime-Based Index Management](#datetime-based-index-management)
|
|
119
120
|
|
|
120
121
|
## Documentation & Resources
|
|
121
122
|
|
|
@@ -236,28 +237,105 @@ You can customize additional settings in your `.env` file:
|
|
|
236
237
|
|------------------------------|--------------------------------------------------------------------------------------|--------------------------|---------------------------------------------------------------------------------------------|
|
|
237
238
|
| `ES_HOST` | Hostname for external Elasticsearch/OpenSearch. | `localhost` | Optional |
|
|
238
239
|
| `ES_PORT` | Port for Elasticsearch/OpenSearch. | `9200` (ES) / `9202` (OS)| Optional |
|
|
239
|
-
| `ES_USE_SSL` | Use SSL for connecting to Elasticsearch/OpenSearch. | `
|
|
240
|
-
| `ES_VERIFY_CERTS` | Verify SSL certificates when connecting. | `
|
|
240
|
+
| `ES_USE_SSL` | Use SSL for connecting to Elasticsearch/OpenSearch. | `true` | Optional |
|
|
241
|
+
| `ES_VERIFY_CERTS` | Verify SSL certificates when connecting. | `true` | Optional |
|
|
242
|
+
| `ES_API_KEY` | API Key for external Elasticsearch/OpenSearch. | N/A | Optional |
|
|
243
|
+
| `ES_TIMEOUT` | Client timeout for Elasticsearch/OpenSearch. | DB client default | Optional |
|
|
241
244
|
| `STAC_FASTAPI_TITLE` | Title of the API in the documentation. | `stac-fastapi-<backend>` | Optional |
|
|
242
245
|
| `STAC_FASTAPI_DESCRIPTION` | Description of the API in the documentation. | N/A | Optional |
|
|
243
246
|
| `STAC_FASTAPI_VERSION` | API version. | `2.1` | Optional |
|
|
244
|
-
| `STAC_FASTAPI_LANDING_PAGE_ID` | Landing page ID
|
|
247
|
+
| `STAC_FASTAPI_LANDING_PAGE_ID` | Landing page ID | `stac-fastapi` | Optional |
|
|
245
248
|
| `APP_HOST` | Server bind address. | `0.0.0.0` | Optional |
|
|
246
|
-
| `APP_PORT` | Server port. | `
|
|
249
|
+
| `APP_PORT` | Server port. | `8000` | Optional |
|
|
247
250
|
| `ENVIRONMENT` | Runtime environment. | `local` | Optional |
|
|
248
251
|
| `WEB_CONCURRENCY` | Number of worker processes. | `10` | Optional |
|
|
249
252
|
| `RELOAD` | Enable auto-reload for development. | `true` | Optional |
|
|
250
253
|
| `STAC_FASTAPI_RATE_LIMIT` | API rate limit per client. | `200/minute` | Optional |
|
|
251
|
-
| `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional
|
|
252
|
-
| `ELASTICSEARCH_VERSION`
|
|
253
|
-
| `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional
|
|
254
|
-
| `ENABLE_DIRECT_RESPONSE`
|
|
255
|
-
| `RAISE_ON_BULK_ERROR`
|
|
256
|
-
| `DATABASE_REFRESH`
|
|
254
|
+
| `BACKEND` | Tests-related variable | `elasticsearch` or `opensearch` based on the backend | Optional |
|
|
255
|
+
| `ELASTICSEARCH_VERSION` | Version of Elasticsearch to use. | `8.11.0` | Optional |
|
|
256
|
+
| `OPENSEARCH_VERSION` | OpenSearch version | `2.11.1` | Optional |
|
|
257
|
+
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
258
|
+
| `RAISE_ON_BULK_ERROR` | Controls whether bulk insert operations raise exceptions on errors. If set to `true`, the operation will stop and raise an exception when an error occurs. If set to `false`, errors will be logged, and the operation will continue. **Note:** STAC Item and ItemCollection validation errors will always raise, regardless of this flag. | `false` | Optional |
|
|
259
|
+
| `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 |
|
|
257
260
|
| `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 |
|
|
258
261
|
|
|
259
262
|
> [!NOTE]
|
|
260
|
-
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, and `
|
|
263
|
+
> The variables `ES_HOST`, `ES_PORT`, `ES_USE_SSL`, `ES_VERIFY_CERTS` and `ES_TIMEOUT` apply to both Elasticsearch and OpenSearch backends, so there is no need to rename the key names to `OS_` even if you're using OpenSearch.
|
|
264
|
+
|
|
265
|
+
## Datetime-Based Index Management
|
|
266
|
+
|
|
267
|
+
### Overview
|
|
268
|
+
|
|
269
|
+
SFEOS supports two indexing strategies for managing STAC items:
|
|
270
|
+
|
|
271
|
+
1. **Simple Indexing** (default) - One index per collection
|
|
272
|
+
2. **Datetime-Based Indexing** - Time-partitioned indexes with automatic management
|
|
273
|
+
|
|
274
|
+
The datetime-based indexing strategy is particularly useful for large temporal datasets. When a user provides a datetime parameter in a query, the system knows exactly which index to search, providing **multiple times faster searches** and significantly **reducing database load**.
|
|
275
|
+
|
|
276
|
+
### When to Use
|
|
277
|
+
|
|
278
|
+
**Recommended for:**
|
|
279
|
+
- Systems with large collections containing millions of items
|
|
280
|
+
- Systems requiring high-performance temporal searching
|
|
281
|
+
|
|
282
|
+
**Pros:**
|
|
283
|
+
- Multiple times faster queries with datetime filter
|
|
284
|
+
- Reduced database load - only relevant indexes are searched
|
|
285
|
+
|
|
286
|
+
**Cons:**
|
|
287
|
+
- Slightly longer item indexing time (automatic index management)
|
|
288
|
+
- Greater management complexity
|
|
289
|
+
|
|
290
|
+
### Configuration
|
|
291
|
+
|
|
292
|
+
#### Enabling Datetime-Based Indexing
|
|
293
|
+
|
|
294
|
+
Enable datetime-based indexing by setting the following environment variable:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
ENABLE_DATETIME_INDEX_FILTERING=true
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Related Configuration Variables
|
|
301
|
+
|
|
302
|
+
| Variable | Description | Default | Example |
|
|
303
|
+
|----------|-------------|---------|---------|
|
|
304
|
+
| `ENABLE_DATETIME_INDEX_FILTERING` | Enables time-based index partitioning | `false` | `true` |
|
|
305
|
+
| `DATETIME_INDEX_MAX_SIZE_GB` | Maximum size limit for datetime indexes (GB) - note: add +20% to target size due to ES/OS compression | `25` | `50` |
|
|
306
|
+
| `STAC_ITEMS_INDEX_PREFIX` | Prefix for item indexes | `items_` | `stac_items_` |
|
|
307
|
+
|
|
308
|
+
## How Datetime-Based Indexing Works
|
|
309
|
+
|
|
310
|
+
### Index and Alias Naming Convention
|
|
311
|
+
|
|
312
|
+
The system uses a precise naming convention:
|
|
313
|
+
|
|
314
|
+
**Physical indexes:**
|
|
315
|
+
```
|
|
316
|
+
{ITEMS_INDEX_PREFIX}{collection-id}_{uuid4}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**Aliases:**
|
|
320
|
+
```
|
|
321
|
+
{ITEMS_INDEX_PREFIX}{collection-id} # Main collection alias
|
|
322
|
+
{ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime} # Temporal alias
|
|
323
|
+
{ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime}_{end-datetime} # Closed index alias
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
**Example:**
|
|
327
|
+
|
|
328
|
+
*Physical indexes:*
|
|
329
|
+
- `items_sentinel-2-l2a_a1b2c3d4-e5f6-7890-abcd-ef1234567890`
|
|
330
|
+
|
|
331
|
+
*Aliases:*
|
|
332
|
+
- `items_sentinel-2-l2a` - main collection alias
|
|
333
|
+
- `items_sentinel-2-l2a_2024-01-01` - active alias from January 1, 2024
|
|
334
|
+
- `items_sentinel-2-l2a_2024-01-01_2024-03-15` - closed index alias (reached size limit)
|
|
335
|
+
|
|
336
|
+
### Index Size Management
|
|
337
|
+
|
|
338
|
+
**Important - Data Compression:** Elasticsearch and OpenSearch automatically compress data. The configured `DATETIME_INDEX_MAX_SIZE_GB` limit refers to the compressed size on disk. It is recommended to add +20% to the target size to account for compression overhead and metadata.
|
|
261
339
|
|
|
262
340
|
## Interacting with the API
|
|
263
341
|
|
|
@@ -567,4 +645,3 @@ You can customize additional settings in your `.env` file:
|
|
|
567
645
|
- Ensures fair resource allocation among all clients
|
|
568
646
|
|
|
569
647
|
- **Examples**: Implementation examples are available in the [examples/rate_limit](examples/rate_limit) directory.
|
|
570
|
-
|
|
@@ -2,14 +2,14 @@ stac_fastapi/core/__init__.py,sha256=8izV3IWRGdXmDOK1hIPQAanbWs9EI04PJCGgqG1ZGIs
|
|
|
2
2
|
stac_fastapi/core/base_database_logic.py,sha256=AcvS38fWUk44BHD1vJfQENKHx1LDQdvRjMqcSQBFqw4,3189
|
|
3
3
|
stac_fastapi/core/base_settings.py,sha256=R3_Sx7n5XpGMs3zAwFJD7y008WvGU_uI2xkaabm82Kg,239
|
|
4
4
|
stac_fastapi/core/basic_auth.py,sha256=RhFv3RVSHF6OaqnaaU2DO4ncJ_S5nB1q8UNpnVJJsrk,2155
|
|
5
|
-
stac_fastapi/core/core.py,sha256=
|
|
6
|
-
stac_fastapi/core/datetime_utils.py,sha256=
|
|
5
|
+
stac_fastapi/core/core.py,sha256=IvvmQYqP5siJXjdPGfldJvosw653cfC7-H7Zw7WFWAc,36626
|
|
6
|
+
stac_fastapi/core/datetime_utils.py,sha256=99vlw-fo0OB_aYfBHXhOkZNxrl2sKr6ZX0oR4PfIQH4,2528
|
|
7
7
|
stac_fastapi/core/rate_limit.py,sha256=Gu8dAaJReGsj1L91U6m2tflU6RahpXDRs2-AYSKoybA,1318
|
|
8
8
|
stac_fastapi/core/route_dependencies.py,sha256=hdtuMkv-zY1vg0YxiCz1aKP0SbBcORqDGEKDGgEazW8,5482
|
|
9
|
-
stac_fastapi/core/serializers.py,sha256
|
|
10
|
-
stac_fastapi/core/session.py,sha256=
|
|
9
|
+
stac_fastapi/core/serializers.py,sha256=-DdbKYkYxmNyhuGc9UMrtFFlwiQpfxhzlog27qpMIpw,6229
|
|
10
|
+
stac_fastapi/core/session.py,sha256=aXqu4LXfVbAAsChMVXd9gAhczA2bZPne6HqPeklAwMY,474
|
|
11
11
|
stac_fastapi/core/utilities.py,sha256=xXWO5oJCNDi7_C5jPYlHZD0B-DL-FN66eEUBUSW-cXw,7296
|
|
12
|
-
stac_fastapi/core/version.py,sha256=
|
|
12
|
+
stac_fastapi/core/version.py,sha256=ro2d3oERQL2KxSo7qmbU0z6qT77XShwY6vsqrLf2VFw,45
|
|
13
13
|
stac_fastapi/core/extensions/__init__.py,sha256=2MCo0UoInkgItIM8id-rbeygzn_qUOvTGfr8jFXZjHQ,167
|
|
14
14
|
stac_fastapi/core/extensions/aggregation.py,sha256=v1hUHqlYuMqfQ554g3cTp16pUyRYucQxPERbHPAFtf8,1878
|
|
15
15
|
stac_fastapi/core/extensions/fields.py,sha256=NCT5XHvfaf297eDPNaIFsIzvJnbbUTpScqF0otdx0NA,1066
|
|
@@ -18,7 +18,7 @@ stac_fastapi/core/extensions/query.py,sha256=Xmo8pfZEZKPudZEjjozv3R0wLOP0ayjC9E6
|
|
|
18
18
|
stac_fastapi/core/models/__init__.py,sha256=g-D1DiGfmC9Bg27DW9JzkN6fAvscv75wyhyiZ6NzvIk,48
|
|
19
19
|
stac_fastapi/core/models/links.py,sha256=3jk4t2wA3RGTq9_BbzFsMKvMbgDBajQy4vKZFSHt7E8,6666
|
|
20
20
|
stac_fastapi/core/models/search.py,sha256=7SgAUyzHGXBXSqB4G6cwq9FMwoAS00momb7jvBkjyow,27
|
|
21
|
-
stac_fastapi_core-6.
|
|
22
|
-
stac_fastapi_core-6.
|
|
23
|
-
stac_fastapi_core-6.
|
|
24
|
-
stac_fastapi_core-6.
|
|
21
|
+
stac_fastapi_core-6.2.0.dist-info/METADATA,sha256=q3akxCvRgSpSAAW4a0suDCzS-Pc5h4a-twTpcGZ_EM4,34717
|
|
22
|
+
stac_fastapi_core-6.2.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
23
|
+
stac_fastapi_core-6.2.0.dist-info/top_level.txt,sha256=vqn-D9-HsRPTTxy0Vk_KkDmTiMES4owwBQ3ydSZYb2s,13
|
|
24
|
+
stac_fastapi_core-6.2.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|