stac-fastapi-core 6.3.0__tar.gz → 6.4.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.
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/PKG-INFO +40 -3
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/README.md +39 -2
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/base_database_logic.py +18 -4
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/core.py +52 -5
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/extensions/filter.py +0 -18
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/models/links.py +1 -1
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/version.py +1 -1
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi_core.egg-info/PKG-INFO +40 -3
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/setup.cfg +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/setup.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/__init__.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/base_settings.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/basic_auth.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/datetime_utils.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/extensions/__init__.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/extensions/aggregation.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/extensions/fields.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/extensions/query.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/models/__init__.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/models/search.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/rate_limit.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/route_dependencies.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/serializers.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/session.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/utilities.py +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi_core.egg-info/SOURCES.txt +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi_core.egg-info/dependency_links.txt +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi_core.egg-info/not-zip-safe +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi_core.egg-info/requires.txt +0 -0
- {stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.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.
|
|
3
|
+
Version: 6.4.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
|
|
@@ -54,11 +54,10 @@ SFEOS (stac-fastapi-elasticsearch-opensearch) is a high-performance, scalable AP
|
|
|
54
54
|
- **Scale to millions of geospatial assets** with fast search performance through optimized spatial indexing and query capabilities
|
|
55
55
|
- **Support OGC-compliant filtering** including spatial operations (intersects, contains, etc.) and temporal queries
|
|
56
56
|
- **Perform geospatial aggregations** to analyze data distribution across space and time
|
|
57
|
+
- **Enhanced collection search capabilities** with support for sorting and field selection
|
|
57
58
|
|
|
58
59
|
This implementation builds on the STAC-FastAPI framework, providing a production-ready solution specifically optimized for Elasticsearch and OpenSearch databases. It's ideal for organizations managing large geospatial data catalogs who need efficient discovery and access capabilities through standardized APIs.
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
61
|
## Common Deployment Patterns
|
|
63
62
|
|
|
64
63
|
stac-fastapi-elasticsearch-opensearch can be deployed in several ways depending on your needs:
|
|
@@ -90,6 +89,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
90
89
|
- [Common Deployment Patterns](#common-deployment-patterns)
|
|
91
90
|
- [Technologies](#technologies)
|
|
92
91
|
- [Table of Contents](#table-of-contents)
|
|
92
|
+
- [Collection Search Extensions](#collection-search-extensions)
|
|
93
93
|
- [Documentation \& Resources](#documentation--resources)
|
|
94
94
|
- [Package Structure](#package-structure)
|
|
95
95
|
- [Examples](#examples)
|
|
@@ -131,6 +131,37 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
131
131
|
- [Gitter Chat](https://app.gitter.im/#/room/#stac-fastapi-elasticsearch_community:gitter.im) - For real-time discussions
|
|
132
132
|
- [GitHub Discussions](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/discussions) - For longer-form questions and answers
|
|
133
133
|
|
|
134
|
+
## Collection Search Extensions
|
|
135
|
+
|
|
136
|
+
SFEOS implements extended capabilities for the `/collections` endpoint, allowing for more powerful collection discovery:
|
|
137
|
+
|
|
138
|
+
- **Sorting**: Sort collections by sortable fields using the `sortby` parameter
|
|
139
|
+
- Example: `/collections?sortby=+id` (ascending sort by ID)
|
|
140
|
+
- Example: `/collections?sortby=-id` (descending sort by ID)
|
|
141
|
+
- Example: `/collections?sortby=-temporal` (descending sort by temporal extent)
|
|
142
|
+
|
|
143
|
+
- **Field Selection**: Request only specific fields to be returned using the `fields` parameter
|
|
144
|
+
- Example: `/collections?fields=id,title,description`
|
|
145
|
+
- This helps reduce payload size when only certain fields are needed
|
|
146
|
+
|
|
147
|
+
- **Free Text Search**: Search across collection text fields using the `q` parameter
|
|
148
|
+
- Example: `/collections?q=landsat`
|
|
149
|
+
- Searches across multiple text fields including title, description, and keywords
|
|
150
|
+
- Supports partial word matching and relevance-based sorting
|
|
151
|
+
|
|
152
|
+
These extensions make it easier to build user interfaces that display and navigate through collections efficiently.
|
|
153
|
+
|
|
154
|
+
> **Configuration**: Collection search extensions can be disabled by setting the `ENABLE_COLLECTIONS_SEARCH` environment variable to `false`. By default, these extensions are enabled.
|
|
155
|
+
|
|
156
|
+
> **Note**: Sorting is only available on fields that are indexed for sorting in Elasticsearch/OpenSearch. With the default mappings, you can sort on:
|
|
157
|
+
> - `id` (keyword field)
|
|
158
|
+
> - `extent.temporal.interval` (date field)
|
|
159
|
+
> - `temporal` (alias to extent.temporal.interval)
|
|
160
|
+
>
|
|
161
|
+
> Text fields like `title` and `description` are not sortable by default as they use text analysis for better search capabilities. Attempting to sort on these fields will result in a user-friendly error message explaining which fields are sortable and how to make additional fields sortable by updating the mappings.
|
|
162
|
+
>
|
|
163
|
+
> **Important**: Adding keyword fields to make text fields sortable can significantly increase the index size, especially for large text fields. Consider the storage implications when deciding which fields to make sortable.
|
|
164
|
+
|
|
134
165
|
## Package Structure
|
|
135
166
|
|
|
136
167
|
This project is organized into several packages, each with a specific purpose:
|
|
@@ -261,10 +292,12 @@ You can customize additional settings in your `.env` file:
|
|
|
261
292
|
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
262
293
|
| `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 |
|
|
263
294
|
| `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 |
|
|
295
|
+
| `ENABLE_COLLECTIONS_SEARCH` | Enable collection search extensions (sort, fields). | `true` | Optional |
|
|
264
296
|
| `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 |
|
|
265
297
|
| `STAC_ITEM_LIMIT` | Sets the environment variable for result limiting to SFEOS for the number of returned items and STAC collections. | `10` | Optional |
|
|
266
298
|
| `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 |
|
|
267
299
|
| `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 |
|
|
300
|
+
| `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 |
|
|
268
301
|
|
|
269
302
|
> [!NOTE]
|
|
270
303
|
> 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.
|
|
@@ -406,6 +439,10 @@ The system uses a precise naming convention:
|
|
|
406
439
|
- **Root Path Configuration**: The application root path is the base URL by default.
|
|
407
440
|
- For AWS Lambda with Gateway API: Set `STAC_FASTAPI_ROOT_PATH` to match the Gateway API stage name (e.g., `/v1`)
|
|
408
441
|
|
|
442
|
+
- **Feature Configuration**: Control which features are enabled:
|
|
443
|
+
- `ENABLE_COLLECTIONS_SEARCH`: Set to `true` (default) to enable collection search extensions (sort, fields). Set to `false` to disable.
|
|
444
|
+
- `ENABLE_TRANSACTIONS_EXTENSIONS`: Set to `true` (default) to enable transaction extensions. Set to `false` to disable.
|
|
445
|
+
|
|
409
446
|
|
|
410
447
|
## Collection Pagination
|
|
411
448
|
|
|
@@ -36,11 +36,10 @@ SFEOS (stac-fastapi-elasticsearch-opensearch) is a high-performance, scalable AP
|
|
|
36
36
|
- **Scale to millions of geospatial assets** with fast search performance through optimized spatial indexing and query capabilities
|
|
37
37
|
- **Support OGC-compliant filtering** including spatial operations (intersects, contains, etc.) and temporal queries
|
|
38
38
|
- **Perform geospatial aggregations** to analyze data distribution across space and time
|
|
39
|
+
- **Enhanced collection search capabilities** with support for sorting and field selection
|
|
39
40
|
|
|
40
41
|
This implementation builds on the STAC-FastAPI framework, providing a production-ready solution specifically optimized for Elasticsearch and OpenSearch databases. It's ideal for organizations managing large geospatial data catalogs who need efficient discovery and access capabilities through standardized APIs.
|
|
41
42
|
|
|
42
|
-
|
|
43
|
-
|
|
44
43
|
## Common Deployment Patterns
|
|
45
44
|
|
|
46
45
|
stac-fastapi-elasticsearch-opensearch can be deployed in several ways depending on your needs:
|
|
@@ -72,6 +71,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
72
71
|
- [Common Deployment Patterns](#common-deployment-patterns)
|
|
73
72
|
- [Technologies](#technologies)
|
|
74
73
|
- [Table of Contents](#table-of-contents)
|
|
74
|
+
- [Collection Search Extensions](#collection-search-extensions)
|
|
75
75
|
- [Documentation \& Resources](#documentation--resources)
|
|
76
76
|
- [Package Structure](#package-structure)
|
|
77
77
|
- [Examples](#examples)
|
|
@@ -113,6 +113,37 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
113
113
|
- [Gitter Chat](https://app.gitter.im/#/room/#stac-fastapi-elasticsearch_community:gitter.im) - For real-time discussions
|
|
114
114
|
- [GitHub Discussions](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/discussions) - For longer-form questions and answers
|
|
115
115
|
|
|
116
|
+
## Collection Search Extensions
|
|
117
|
+
|
|
118
|
+
SFEOS implements extended capabilities for the `/collections` endpoint, allowing for more powerful collection discovery:
|
|
119
|
+
|
|
120
|
+
- **Sorting**: Sort collections by sortable fields using the `sortby` parameter
|
|
121
|
+
- Example: `/collections?sortby=+id` (ascending sort by ID)
|
|
122
|
+
- Example: `/collections?sortby=-id` (descending sort by ID)
|
|
123
|
+
- Example: `/collections?sortby=-temporal` (descending sort by temporal extent)
|
|
124
|
+
|
|
125
|
+
- **Field Selection**: Request only specific fields to be returned using the `fields` parameter
|
|
126
|
+
- Example: `/collections?fields=id,title,description`
|
|
127
|
+
- This helps reduce payload size when only certain fields are needed
|
|
128
|
+
|
|
129
|
+
- **Free Text Search**: Search across collection text fields using the `q` parameter
|
|
130
|
+
- Example: `/collections?q=landsat`
|
|
131
|
+
- Searches across multiple text fields including title, description, and keywords
|
|
132
|
+
- Supports partial word matching and relevance-based sorting
|
|
133
|
+
|
|
134
|
+
These extensions make it easier to build user interfaces that display and navigate through collections efficiently.
|
|
135
|
+
|
|
136
|
+
> **Configuration**: Collection search extensions can be disabled by setting the `ENABLE_COLLECTIONS_SEARCH` environment variable to `false`. By default, these extensions are enabled.
|
|
137
|
+
|
|
138
|
+
> **Note**: Sorting is only available on fields that are indexed for sorting in Elasticsearch/OpenSearch. With the default mappings, you can sort on:
|
|
139
|
+
> - `id` (keyword field)
|
|
140
|
+
> - `extent.temporal.interval` (date field)
|
|
141
|
+
> - `temporal` (alias to extent.temporal.interval)
|
|
142
|
+
>
|
|
143
|
+
> Text fields like `title` and `description` are not sortable by default as they use text analysis for better search capabilities. Attempting to sort on these fields will result in a user-friendly error message explaining which fields are sortable and how to make additional fields sortable by updating the mappings.
|
|
144
|
+
>
|
|
145
|
+
> **Important**: Adding keyword fields to make text fields sortable can significantly increase the index size, especially for large text fields. Consider the storage implications when deciding which fields to make sortable.
|
|
146
|
+
|
|
116
147
|
## Package Structure
|
|
117
148
|
|
|
118
149
|
This project is organized into several packages, each with a specific purpose:
|
|
@@ -243,10 +274,12 @@ You can customize additional settings in your `.env` file:
|
|
|
243
274
|
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
244
275
|
| `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 |
|
|
245
276
|
| `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 |
|
|
277
|
+
| `ENABLE_COLLECTIONS_SEARCH` | Enable collection search extensions (sort, fields). | `true` | Optional |
|
|
246
278
|
| `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 |
|
|
247
279
|
| `STAC_ITEM_LIMIT` | Sets the environment variable for result limiting to SFEOS for the number of returned items and STAC collections. | `10` | Optional |
|
|
248
280
|
| `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 |
|
|
249
281
|
| `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 |
|
|
282
|
+
| `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 |
|
|
250
283
|
|
|
251
284
|
> [!NOTE]
|
|
252
285
|
> 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.
|
|
@@ -388,6 +421,10 @@ The system uses a precise naming convention:
|
|
|
388
421
|
- **Root Path Configuration**: The application root path is the base URL by default.
|
|
389
422
|
- For AWS Lambda with Gateway API: Set `STAC_FASTAPI_ROOT_PATH` to match the Gateway API stage name (e.g., `/v1`)
|
|
390
423
|
|
|
424
|
+
- **Feature Configuration**: Control which features are enabled:
|
|
425
|
+
- `ENABLE_COLLECTIONS_SEARCH`: Set to `true` (default) to enable collection search extensions (sort, fields). Set to `false` to disable.
|
|
426
|
+
- `ENABLE_TRANSACTIONS_EXTENSIONS`: Set to `true` (default) to enable transaction extensions. Set to `false` to disable.
|
|
427
|
+
|
|
391
428
|
|
|
392
429
|
## Collection Pagination
|
|
393
430
|
|
{stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/base_database_logic.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Base database logic."""
|
|
2
2
|
|
|
3
3
|
import abc
|
|
4
|
-
from typing import Any, Dict, Iterable, List, Optional
|
|
4
|
+
from typing import Any, Dict, Iterable, List, Optional, Tuple
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class BaseDatabaseLogic(abc.ABC):
|
|
@@ -14,9 +14,23 @@ class BaseDatabaseLogic(abc.ABC):
|
|
|
14
14
|
|
|
15
15
|
@abc.abstractmethod
|
|
16
16
|
async def get_all_collections(
|
|
17
|
-
self,
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
self,
|
|
18
|
+
token: Optional[str],
|
|
19
|
+
limit: int,
|
|
20
|
+
request: Any = None,
|
|
21
|
+
sort: Optional[List[Dict[str, Any]]] = None,
|
|
22
|
+
) -> Tuple[List[Dict[str, Any]], Optional[str]]:
|
|
23
|
+
"""Retrieve a list of collections from the database, supporting pagination.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
token (Optional[str]): The pagination token.
|
|
27
|
+
limit (int): The number of results to return.
|
|
28
|
+
request (Any, optional): The FastAPI request object. Defaults to None.
|
|
29
|
+
sort (Optional[List[Dict[str, Any]]], optional): Optional sort parameter. Defaults to None.
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
A tuple of (collections, next pagination token if any).
|
|
33
|
+
"""
|
|
20
34
|
pass
|
|
21
35
|
|
|
22
36
|
@abc.abstractmethod
|
|
@@ -224,10 +224,19 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
224
224
|
|
|
225
225
|
return landing_page
|
|
226
226
|
|
|
227
|
-
async def all_collections(
|
|
227
|
+
async def all_collections(
|
|
228
|
+
self,
|
|
229
|
+
fields: Optional[List[str]] = None,
|
|
230
|
+
sortby: Optional[str] = None,
|
|
231
|
+
q: Optional[Union[str, List[str]]] = None,
|
|
232
|
+
**kwargs,
|
|
233
|
+
) -> stac_types.Collections:
|
|
228
234
|
"""Read all collections from the database.
|
|
229
235
|
|
|
230
236
|
Args:
|
|
237
|
+
fields (Optional[List[str]]): Fields to include or exclude from the results.
|
|
238
|
+
sortby (Optional[str]): Sorting options for the results.
|
|
239
|
+
q (Optional[List[str]]): Free text search terms.
|
|
231
240
|
**kwargs: Keyword arguments from the request.
|
|
232
241
|
|
|
233
242
|
Returns:
|
|
@@ -238,10 +247,48 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
238
247
|
limit = int(request.query_params.get("limit", os.getenv("STAC_ITEM_LIMIT", 10)))
|
|
239
248
|
token = request.query_params.get("token")
|
|
240
249
|
|
|
250
|
+
# Process fields parameter for filtering collection properties
|
|
251
|
+
includes, excludes = set(), set()
|
|
252
|
+
if fields and self.extension_is_enabled("FieldsExtension"):
|
|
253
|
+
for field in fields:
|
|
254
|
+
if field[0] == "-":
|
|
255
|
+
excludes.add(field[1:])
|
|
256
|
+
else:
|
|
257
|
+
includes.add(field[1:] if field[0] in "+ " else field)
|
|
258
|
+
|
|
259
|
+
sort = None
|
|
260
|
+
if sortby:
|
|
261
|
+
parsed_sort = []
|
|
262
|
+
for raw in sortby:
|
|
263
|
+
if not isinstance(raw, str):
|
|
264
|
+
continue
|
|
265
|
+
s = raw.strip()
|
|
266
|
+
if not s:
|
|
267
|
+
continue
|
|
268
|
+
direction = "desc" if s[0] == "-" else "asc"
|
|
269
|
+
field = s[1:] if s and s[0] in "+-" else s
|
|
270
|
+
parsed_sort.append({"field": field, "direction": direction})
|
|
271
|
+
if parsed_sort:
|
|
272
|
+
sort = parsed_sort
|
|
273
|
+
|
|
274
|
+
# Convert q to a list if it's a string
|
|
275
|
+
q_list = None
|
|
276
|
+
if q is not None:
|
|
277
|
+
q_list = [q] if isinstance(q, str) else q
|
|
278
|
+
|
|
241
279
|
collections, next_token = await self.database.get_all_collections(
|
|
242
|
-
token=token, limit=limit, request=request
|
|
280
|
+
token=token, limit=limit, request=request, sort=sort, q=q_list
|
|
243
281
|
)
|
|
244
282
|
|
|
283
|
+
# Apply field filtering if fields parameter was provided
|
|
284
|
+
if fields and self.extension_is_enabled("FieldsExtension"):
|
|
285
|
+
filtered_collections = [
|
|
286
|
+
filter_fields(collection, includes, excludes)
|
|
287
|
+
for collection in collections
|
|
288
|
+
]
|
|
289
|
+
else:
|
|
290
|
+
filtered_collections = collections
|
|
291
|
+
|
|
245
292
|
links = [
|
|
246
293
|
{"rel": Relations.root.value, "type": MimeTypes.json, "href": base_url},
|
|
247
294
|
{"rel": Relations.parent.value, "type": MimeTypes.json, "href": base_url},
|
|
@@ -256,7 +303,7 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
256
303
|
next_link = PagingLinks(next=next_token, request=request).link_next()
|
|
257
304
|
links.append(next_link)
|
|
258
305
|
|
|
259
|
-
return stac_types.Collections(collections=
|
|
306
|
+
return stac_types.Collections(collections=filtered_collections, links=links)
|
|
260
307
|
|
|
261
308
|
async def get_collection(
|
|
262
309
|
self, collection_id: str, **kwargs
|
|
@@ -596,8 +643,8 @@ class CoreClient(AsyncBaseCoreClient):
|
|
|
596
643
|
type="FeatureCollection",
|
|
597
644
|
features=items,
|
|
598
645
|
links=links,
|
|
599
|
-
|
|
600
|
-
|
|
646
|
+
numberReturned=len(items),
|
|
647
|
+
numberMatched=maybe_count,
|
|
601
648
|
)
|
|
602
649
|
|
|
603
650
|
|
|
@@ -41,24 +41,6 @@ DEFAULT_QUERYABLES: Dict[str, Dict[str, Any]] = {
|
|
|
41
41
|
"description": "Creation Timestamp",
|
|
42
42
|
"$ref": "https://schemas.stacspec.org/v1.0.0/item-spec/json-schema/datetime.json#/properties/updated",
|
|
43
43
|
},
|
|
44
|
-
"cloud_cover": {
|
|
45
|
-
"description": "Cloud Cover",
|
|
46
|
-
"$ref": "https://stac-extensions.github.io/eo/v1.0.0/schema.json#/definitions/fields/properties/eo:cloud_cover",
|
|
47
|
-
},
|
|
48
|
-
"cloud_shadow_percentage": {
|
|
49
|
-
"title": "Cloud Shadow Percentage",
|
|
50
|
-
"description": "Cloud Shadow Percentage",
|
|
51
|
-
"type": "number",
|
|
52
|
-
"minimum": 0,
|
|
53
|
-
"maximum": 100,
|
|
54
|
-
},
|
|
55
|
-
"nodata_pixel_percentage": {
|
|
56
|
-
"title": "No Data Pixel Percentage",
|
|
57
|
-
"description": "No Data Pixel Percentage",
|
|
58
|
-
"type": "number",
|
|
59
|
-
"minimum": 0,
|
|
60
|
-
"maximum": 100,
|
|
61
|
-
},
|
|
62
44
|
}
|
|
63
45
|
"""Queryables that are present in all collections."""
|
|
64
46
|
|
|
@@ -139,7 +139,7 @@ class CollectionLinks(BaseLinks):
|
|
|
139
139
|
if "FilterExtension" in self.extensions:
|
|
140
140
|
return dict(
|
|
141
141
|
rel="queryables",
|
|
142
|
-
type=MimeTypes.
|
|
142
|
+
type=MimeTypes.jsonschema.value,
|
|
143
143
|
href=urljoin(
|
|
144
144
|
self.base_url, f"collections/{self.collection_id}/queryables"
|
|
145
145
|
),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""library version."""
|
|
2
|
-
__version__ = "6.
|
|
2
|
+
__version__ = "6.4.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stac-fastapi-core
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.4.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
|
|
@@ -54,11 +54,10 @@ SFEOS (stac-fastapi-elasticsearch-opensearch) is a high-performance, scalable AP
|
|
|
54
54
|
- **Scale to millions of geospatial assets** with fast search performance through optimized spatial indexing and query capabilities
|
|
55
55
|
- **Support OGC-compliant filtering** including spatial operations (intersects, contains, etc.) and temporal queries
|
|
56
56
|
- **Perform geospatial aggregations** to analyze data distribution across space and time
|
|
57
|
+
- **Enhanced collection search capabilities** with support for sorting and field selection
|
|
57
58
|
|
|
58
59
|
This implementation builds on the STAC-FastAPI framework, providing a production-ready solution specifically optimized for Elasticsearch and OpenSearch databases. It's ideal for organizations managing large geospatial data catalogs who need efficient discovery and access capabilities through standardized APIs.
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
61
|
## Common Deployment Patterns
|
|
63
62
|
|
|
64
63
|
stac-fastapi-elasticsearch-opensearch can be deployed in several ways depending on your needs:
|
|
@@ -90,6 +89,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
90
89
|
- [Common Deployment Patterns](#common-deployment-patterns)
|
|
91
90
|
- [Technologies](#technologies)
|
|
92
91
|
- [Table of Contents](#table-of-contents)
|
|
92
|
+
- [Collection Search Extensions](#collection-search-extensions)
|
|
93
93
|
- [Documentation \& Resources](#documentation--resources)
|
|
94
94
|
- [Package Structure](#package-structure)
|
|
95
95
|
- [Examples](#examples)
|
|
@@ -131,6 +131,37 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
131
131
|
- [Gitter Chat](https://app.gitter.im/#/room/#stac-fastapi-elasticsearch_community:gitter.im) - For real-time discussions
|
|
132
132
|
- [GitHub Discussions](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/discussions) - For longer-form questions and answers
|
|
133
133
|
|
|
134
|
+
## Collection Search Extensions
|
|
135
|
+
|
|
136
|
+
SFEOS implements extended capabilities for the `/collections` endpoint, allowing for more powerful collection discovery:
|
|
137
|
+
|
|
138
|
+
- **Sorting**: Sort collections by sortable fields using the `sortby` parameter
|
|
139
|
+
- Example: `/collections?sortby=+id` (ascending sort by ID)
|
|
140
|
+
- Example: `/collections?sortby=-id` (descending sort by ID)
|
|
141
|
+
- Example: `/collections?sortby=-temporal` (descending sort by temporal extent)
|
|
142
|
+
|
|
143
|
+
- **Field Selection**: Request only specific fields to be returned using the `fields` parameter
|
|
144
|
+
- Example: `/collections?fields=id,title,description`
|
|
145
|
+
- This helps reduce payload size when only certain fields are needed
|
|
146
|
+
|
|
147
|
+
- **Free Text Search**: Search across collection text fields using the `q` parameter
|
|
148
|
+
- Example: `/collections?q=landsat`
|
|
149
|
+
- Searches across multiple text fields including title, description, and keywords
|
|
150
|
+
- Supports partial word matching and relevance-based sorting
|
|
151
|
+
|
|
152
|
+
These extensions make it easier to build user interfaces that display and navigate through collections efficiently.
|
|
153
|
+
|
|
154
|
+
> **Configuration**: Collection search extensions can be disabled by setting the `ENABLE_COLLECTIONS_SEARCH` environment variable to `false`. By default, these extensions are enabled.
|
|
155
|
+
|
|
156
|
+
> **Note**: Sorting is only available on fields that are indexed for sorting in Elasticsearch/OpenSearch. With the default mappings, you can sort on:
|
|
157
|
+
> - `id` (keyword field)
|
|
158
|
+
> - `extent.temporal.interval` (date field)
|
|
159
|
+
> - `temporal` (alias to extent.temporal.interval)
|
|
160
|
+
>
|
|
161
|
+
> Text fields like `title` and `description` are not sortable by default as they use text analysis for better search capabilities. Attempting to sort on these fields will result in a user-friendly error message explaining which fields are sortable and how to make additional fields sortable by updating the mappings.
|
|
162
|
+
>
|
|
163
|
+
> **Important**: Adding keyword fields to make text fields sortable can significantly increase the index size, especially for large text fields. Consider the storage implications when deciding which fields to make sortable.
|
|
164
|
+
|
|
134
165
|
## Package Structure
|
|
135
166
|
|
|
136
167
|
This project is organized into several packages, each with a specific purpose:
|
|
@@ -261,10 +292,12 @@ You can customize additional settings in your `.env` file:
|
|
|
261
292
|
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
262
293
|
| `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 |
|
|
263
294
|
| `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 |
|
|
295
|
+
| `ENABLE_COLLECTIONS_SEARCH` | Enable collection search extensions (sort, fields). | `true` | Optional |
|
|
264
296
|
| `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 |
|
|
265
297
|
| `STAC_ITEM_LIMIT` | Sets the environment variable for result limiting to SFEOS for the number of returned items and STAC collections. | `10` | Optional |
|
|
266
298
|
| `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 |
|
|
267
299
|
| `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 |
|
|
300
|
+
| `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 |
|
|
268
301
|
|
|
269
302
|
> [!NOTE]
|
|
270
303
|
> 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.
|
|
@@ -406,6 +439,10 @@ The system uses a precise naming convention:
|
|
|
406
439
|
- **Root Path Configuration**: The application root path is the base URL by default.
|
|
407
440
|
- For AWS Lambda with Gateway API: Set `STAC_FASTAPI_ROOT_PATH` to match the Gateway API stage name (e.g., `/v1`)
|
|
408
441
|
|
|
442
|
+
- **Feature Configuration**: Control which features are enabled:
|
|
443
|
+
- `ENABLE_COLLECTIONS_SEARCH`: Set to `true` (default) to enable collection search extensions (sort, fields). Set to `false` to disable.
|
|
444
|
+
- `ENABLE_TRANSACTIONS_EXTENSIONS`: Set to `true` (default) to enable transaction extensions. Set to `false` to disable.
|
|
445
|
+
|
|
409
446
|
|
|
410
447
|
## Collection Pagination
|
|
411
448
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/extensions/__init__.py
RENAMED
|
File without changes
|
{stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi/core/extensions/aggregation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi_core.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stac_fastapi_core-6.3.0 → stac_fastapi_core-6.4.0}/stac_fastapi_core.egg-info/top_level.txt
RENAMED
|
File without changes
|