stac-fastapi-core 6.1.0__tar.gz → 6.2.0__tar.gz

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.
Files changed (30) hide show
  1. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/PKG-INFO +77 -2
  2. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/README.md +76 -1
  3. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/core.py +18 -6
  4. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/datetime_utils.py +1 -0
  5. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/serializers.py +1 -0
  6. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/session.py +1 -0
  7. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/version.py +1 -1
  8. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi_core.egg-info/PKG-INFO +77 -2
  9. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/setup.cfg +0 -0
  10. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/setup.py +0 -0
  11. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/__init__.py +0 -0
  12. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/base_database_logic.py +0 -0
  13. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/base_settings.py +0 -0
  14. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/basic_auth.py +0 -0
  15. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/extensions/__init__.py +0 -0
  16. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/extensions/aggregation.py +0 -0
  17. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/extensions/fields.py +0 -0
  18. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/extensions/filter.py +0 -0
  19. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/extensions/query.py +0 -0
  20. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/models/__init__.py +0 -0
  21. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/models/links.py +0 -0
  22. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/models/search.py +0 -0
  23. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/rate_limit.py +0 -0
  24. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/route_dependencies.py +0 -0
  25. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi/core/utilities.py +0 -0
  26. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi_core.egg-info/SOURCES.txt +0 -0
  27. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi_core.egg-info/dependency_links.txt +0 -0
  28. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi_core.egg-info/not-zip-safe +0 -0
  29. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi_core.egg-info/requires.txt +0 -0
  30. {stac_fastapi_core-6.1.0 → stac_fastapi_core-6.2.0}/stac_fastapi_core.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac_fastapi_core
3
- Version: 6.1.0
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
@@ -103,6 +103,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
103
103
  - [Auth](#auth)
104
104
  - [Aggregation](#aggregation)
105
105
  - [Rate Limiting](#rate-limiting)
106
+ - [Datetime-Based Index Management](#datetime-based-index-management)
106
107
 
107
108
  ## Documentation & Resources
108
109
 
@@ -248,6 +249,81 @@ You can customize additional settings in your `.env` file:
248
249
  > [!NOTE]
249
250
  > 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.
250
251
 
252
+ ## Datetime-Based Index Management
253
+
254
+ ### Overview
255
+
256
+ SFEOS supports two indexing strategies for managing STAC items:
257
+
258
+ 1. **Simple Indexing** (default) - One index per collection
259
+ 2. **Datetime-Based Indexing** - Time-partitioned indexes with automatic management
260
+
261
+ 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**.
262
+
263
+ ### When to Use
264
+
265
+ **Recommended for:**
266
+ - Systems with large collections containing millions of items
267
+ - Systems requiring high-performance temporal searching
268
+
269
+ **Pros:**
270
+ - Multiple times faster queries with datetime filter
271
+ - Reduced database load - only relevant indexes are searched
272
+
273
+ **Cons:**
274
+ - Slightly longer item indexing time (automatic index management)
275
+ - Greater management complexity
276
+
277
+ ### Configuration
278
+
279
+ #### Enabling Datetime-Based Indexing
280
+
281
+ Enable datetime-based indexing by setting the following environment variable:
282
+
283
+ ```bash
284
+ ENABLE_DATETIME_INDEX_FILTERING=true
285
+ ```
286
+
287
+ ### Related Configuration Variables
288
+
289
+ | Variable | Description | Default | Example |
290
+ |----------|-------------|---------|---------|
291
+ | `ENABLE_DATETIME_INDEX_FILTERING` | Enables time-based index partitioning | `false` | `true` |
292
+ | `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` |
293
+ | `STAC_ITEMS_INDEX_PREFIX` | Prefix for item indexes | `items_` | `stac_items_` |
294
+
295
+ ## How Datetime-Based Indexing Works
296
+
297
+ ### Index and Alias Naming Convention
298
+
299
+ The system uses a precise naming convention:
300
+
301
+ **Physical indexes:**
302
+ ```
303
+ {ITEMS_INDEX_PREFIX}{collection-id}_{uuid4}
304
+ ```
305
+
306
+ **Aliases:**
307
+ ```
308
+ {ITEMS_INDEX_PREFIX}{collection-id} # Main collection alias
309
+ {ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime} # Temporal alias
310
+ {ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime}_{end-datetime} # Closed index alias
311
+ ```
312
+
313
+ **Example:**
314
+
315
+ *Physical indexes:*
316
+ - `items_sentinel-2-l2a_a1b2c3d4-e5f6-7890-abcd-ef1234567890`
317
+
318
+ *Aliases:*
319
+ - `items_sentinel-2-l2a` - main collection alias
320
+ - `items_sentinel-2-l2a_2024-01-01` - active alias from January 1, 2024
321
+ - `items_sentinel-2-l2a_2024-01-01_2024-03-15` - closed index alias (reached size limit)
322
+
323
+ ### Index Size Management
324
+
325
+ **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.
326
+
251
327
  ## Interacting with the API
252
328
 
253
329
  - **Creating a Collection**:
@@ -556,4 +632,3 @@ You can customize additional settings in your `.env` file:
556
632
  - Ensures fair resource allocation among all clients
557
633
 
558
634
  - **Examples**: Implementation examples are available in the [examples/rate_limit](examples/rate_limit) directory.
559
-
@@ -85,6 +85,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
85
85
  - [Auth](#auth)
86
86
  - [Aggregation](#aggregation)
87
87
  - [Rate Limiting](#rate-limiting)
88
+ - [Datetime-Based Index Management](#datetime-based-index-management)
88
89
 
89
90
  ## Documentation & Resources
90
91
 
@@ -230,6 +231,81 @@ You can customize additional settings in your `.env` file:
230
231
  > [!NOTE]
231
232
  > 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.
232
233
 
234
+ ## Datetime-Based Index Management
235
+
236
+ ### Overview
237
+
238
+ SFEOS supports two indexing strategies for managing STAC items:
239
+
240
+ 1. **Simple Indexing** (default) - One index per collection
241
+ 2. **Datetime-Based Indexing** - Time-partitioned indexes with automatic management
242
+
243
+ 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**.
244
+
245
+ ### When to Use
246
+
247
+ **Recommended for:**
248
+ - Systems with large collections containing millions of items
249
+ - Systems requiring high-performance temporal searching
250
+
251
+ **Pros:**
252
+ - Multiple times faster queries with datetime filter
253
+ - Reduced database load - only relevant indexes are searched
254
+
255
+ **Cons:**
256
+ - Slightly longer item indexing time (automatic index management)
257
+ - Greater management complexity
258
+
259
+ ### Configuration
260
+
261
+ #### Enabling Datetime-Based Indexing
262
+
263
+ Enable datetime-based indexing by setting the following environment variable:
264
+
265
+ ```bash
266
+ ENABLE_DATETIME_INDEX_FILTERING=true
267
+ ```
268
+
269
+ ### Related Configuration Variables
270
+
271
+ | Variable | Description | Default | Example |
272
+ |----------|-------------|---------|---------|
273
+ | `ENABLE_DATETIME_INDEX_FILTERING` | Enables time-based index partitioning | `false` | `true` |
274
+ | `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` |
275
+ | `STAC_ITEMS_INDEX_PREFIX` | Prefix for item indexes | `items_` | `stac_items_` |
276
+
277
+ ## How Datetime-Based Indexing Works
278
+
279
+ ### Index and Alias Naming Convention
280
+
281
+ The system uses a precise naming convention:
282
+
283
+ **Physical indexes:**
284
+ ```
285
+ {ITEMS_INDEX_PREFIX}{collection-id}_{uuid4}
286
+ ```
287
+
288
+ **Aliases:**
289
+ ```
290
+ {ITEMS_INDEX_PREFIX}{collection-id} # Main collection alias
291
+ {ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime} # Temporal alias
292
+ {ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime}_{end-datetime} # Closed index alias
293
+ ```
294
+
295
+ **Example:**
296
+
297
+ *Physical indexes:*
298
+ - `items_sentinel-2-l2a_a1b2c3d4-e5f6-7890-abcd-ef1234567890`
299
+
300
+ *Aliases:*
301
+ - `items_sentinel-2-l2a` - main collection alias
302
+ - `items_sentinel-2-l2a_2024-01-01` - active alias from January 1, 2024
303
+ - `items_sentinel-2-l2a_2024-01-01_2024-03-15` - closed index alias (reached size limit)
304
+
305
+ ### Index Size Management
306
+
307
+ **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.
308
+
233
309
  ## Interacting with the API
234
310
 
235
311
  - **Creating a Collection**:
@@ -538,4 +614,3 @@ You can customize additional settings in your `.env` file:
538
614
  - Ensures fair resource allocation among all clients
539
615
 
540
616
  - **Examples**: Implementation examples are available in the [examples/rate_limit](examples/rate_limit) directory.
541
-
@@ -324,10 +324,15 @@ class CoreClient(AsyncBaseCoreClient):
324
324
  search=search, collection_ids=[collection_id]
325
325
  )
326
326
 
327
- if datetime:
328
- search = self.database.apply_datetime_filter(
329
- search=search, interval=datetime
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
- if search_request.datetime:
504
- search = self.database.apply_datetime_filter(
505
- search=search, interval=search_request.datetime
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 = (
@@ -1,4 +1,5 @@
1
1
  """Utility functions to handle datetime parsing."""
2
+
2
3
  from datetime import datetime, timezone
3
4
 
4
5
  from stac_fastapi.types.rfc3339 import rfc3339_str_to_datetime
@@ -1,4 +1,5 @@
1
1
  """Serializers."""
2
+
2
3
  import abc
3
4
  from copy import deepcopy
4
5
  from typing import Any, List, Optional
@@ -1,4 +1,5 @@
1
1
  """database session management."""
2
+
2
3
  import logging
3
4
 
4
5
  import attr
@@ -1,2 +1,2 @@
1
1
  """library version."""
2
- __version__ = "6.1.0"
2
+ __version__ = "6.2.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: stac-fastapi-core
3
- Version: 6.1.0
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
@@ -103,6 +103,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
103
103
  - [Auth](#auth)
104
104
  - [Aggregation](#aggregation)
105
105
  - [Rate Limiting](#rate-limiting)
106
+ - [Datetime-Based Index Management](#datetime-based-index-management)
106
107
 
107
108
  ## Documentation & Resources
108
109
 
@@ -248,6 +249,81 @@ You can customize additional settings in your `.env` file:
248
249
  > [!NOTE]
249
250
  > 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.
250
251
 
252
+ ## Datetime-Based Index Management
253
+
254
+ ### Overview
255
+
256
+ SFEOS supports two indexing strategies for managing STAC items:
257
+
258
+ 1. **Simple Indexing** (default) - One index per collection
259
+ 2. **Datetime-Based Indexing** - Time-partitioned indexes with automatic management
260
+
261
+ 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**.
262
+
263
+ ### When to Use
264
+
265
+ **Recommended for:**
266
+ - Systems with large collections containing millions of items
267
+ - Systems requiring high-performance temporal searching
268
+
269
+ **Pros:**
270
+ - Multiple times faster queries with datetime filter
271
+ - Reduced database load - only relevant indexes are searched
272
+
273
+ **Cons:**
274
+ - Slightly longer item indexing time (automatic index management)
275
+ - Greater management complexity
276
+
277
+ ### Configuration
278
+
279
+ #### Enabling Datetime-Based Indexing
280
+
281
+ Enable datetime-based indexing by setting the following environment variable:
282
+
283
+ ```bash
284
+ ENABLE_DATETIME_INDEX_FILTERING=true
285
+ ```
286
+
287
+ ### Related Configuration Variables
288
+
289
+ | Variable | Description | Default | Example |
290
+ |----------|-------------|---------|---------|
291
+ | `ENABLE_DATETIME_INDEX_FILTERING` | Enables time-based index partitioning | `false` | `true` |
292
+ | `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` |
293
+ | `STAC_ITEMS_INDEX_PREFIX` | Prefix for item indexes | `items_` | `stac_items_` |
294
+
295
+ ## How Datetime-Based Indexing Works
296
+
297
+ ### Index and Alias Naming Convention
298
+
299
+ The system uses a precise naming convention:
300
+
301
+ **Physical indexes:**
302
+ ```
303
+ {ITEMS_INDEX_PREFIX}{collection-id}_{uuid4}
304
+ ```
305
+
306
+ **Aliases:**
307
+ ```
308
+ {ITEMS_INDEX_PREFIX}{collection-id} # Main collection alias
309
+ {ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime} # Temporal alias
310
+ {ITEMS_INDEX_PREFIX}{collection-id}_{start-datetime}_{end-datetime} # Closed index alias
311
+ ```
312
+
313
+ **Example:**
314
+
315
+ *Physical indexes:*
316
+ - `items_sentinel-2-l2a_a1b2c3d4-e5f6-7890-abcd-ef1234567890`
317
+
318
+ *Aliases:*
319
+ - `items_sentinel-2-l2a` - main collection alias
320
+ - `items_sentinel-2-l2a_2024-01-01` - active alias from January 1, 2024
321
+ - `items_sentinel-2-l2a_2024-01-01_2024-03-15` - closed index alias (reached size limit)
322
+
323
+ ### Index Size Management
324
+
325
+ **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.
326
+
251
327
  ## Interacting with the API
252
328
 
253
329
  - **Creating a Collection**:
@@ -556,4 +632,3 @@ You can customize additional settings in your `.env` file:
556
632
  - Ensures fair resource allocation among all clients
557
633
 
558
634
  - **Examples**: Implementation examples are available in the [examples/rate_limit](examples/rate_limit) directory.
559
-