stac-fastapi-elasticsearch 6.3.0__py3-none-any.whl → 6.4.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/elasticsearch/app.py +29 -10
- stac_fastapi/elasticsearch/database_logic.py +173 -54
- stac_fastapi/elasticsearch/version.py +1 -1
- {stac_fastapi_elasticsearch-6.3.0.dist-info → stac_fastapi_elasticsearch-6.4.0.dist-info}/METADATA +42 -5
- stac_fastapi_elasticsearch-6.4.0.dist-info/RECORD +10 -0
- stac_fastapi_elasticsearch-6.3.0.dist-info/RECORD +0 -10
- {stac_fastapi_elasticsearch-6.3.0.dist-info → stac_fastapi_elasticsearch-6.4.0.dist-info}/WHEEL +0 -0
- {stac_fastapi_elasticsearch-6.3.0.dist-info → stac_fastapi_elasticsearch-6.4.0.dist-info}/entry_points.txt +0 -0
- {stac_fastapi_elasticsearch-6.3.0.dist-info → stac_fastapi_elasticsearch-6.4.0.dist-info}/top_level.txt +0 -0
|
@@ -34,7 +34,7 @@ from stac_fastapi.elasticsearch.database_logic import (
|
|
|
34
34
|
create_collection_index,
|
|
35
35
|
create_index_templates,
|
|
36
36
|
)
|
|
37
|
-
from stac_fastapi.extensions.core import (
|
|
37
|
+
from stac_fastapi.extensions.core import ( # CollectionSearchFilterExtension,
|
|
38
38
|
AggregationExtension,
|
|
39
39
|
CollectionSearchExtension,
|
|
40
40
|
FilterExtension,
|
|
@@ -45,6 +45,7 @@ from stac_fastapi.extensions.core import (
|
|
|
45
45
|
)
|
|
46
46
|
from stac_fastapi.extensions.core.fields import FieldsConformanceClasses
|
|
47
47
|
from stac_fastapi.extensions.core.filter import FilterConformanceClasses
|
|
48
|
+
from stac_fastapi.extensions.core.free_text import FreeTextConformanceClasses
|
|
48
49
|
from stac_fastapi.extensions.core.query import QueryConformanceClasses
|
|
49
50
|
from stac_fastapi.extensions.core.sort import SortConformanceClasses
|
|
50
51
|
from stac_fastapi.extensions.third_party import BulkTransactionExtension
|
|
@@ -55,7 +56,9 @@ logging.basicConfig(level=logging.INFO)
|
|
|
55
56
|
logger = logging.getLogger(__name__)
|
|
56
57
|
|
|
57
58
|
TRANSACTIONS_EXTENSIONS = get_bool_env("ENABLE_TRANSACTIONS_EXTENSIONS", default=True)
|
|
59
|
+
ENABLE_COLLECTIONS_SEARCH = get_bool_env("ENABLE_COLLECTIONS_SEARCH", default=True)
|
|
58
60
|
logger.info("TRANSACTIONS_EXTENSIONS is set to %s", TRANSACTIONS_EXTENSIONS)
|
|
61
|
+
logger.info("ENABLE_COLLECTIONS_SEARCH is set to %s", ENABLE_COLLECTIONS_SEARCH)
|
|
59
62
|
|
|
60
63
|
settings = ElasticsearchSettings()
|
|
61
64
|
session = Session.create_from_settings(settings)
|
|
@@ -70,14 +73,6 @@ filter_extension.conformance_classes.append(
|
|
|
70
73
|
FilterConformanceClasses.ADVANCED_COMPARISON_OPERATORS
|
|
71
74
|
)
|
|
72
75
|
|
|
73
|
-
# Adding collection search extension for compatibility with stac-auth-proxy
|
|
74
|
-
# (https://github.com/developmentseed/stac-auth-proxy)
|
|
75
|
-
# The extension is not fully implemented yet but is required for collection filtering support
|
|
76
|
-
collection_search_extension = CollectionSearchExtension()
|
|
77
|
-
collection_search_extension.conformance_classes.append(
|
|
78
|
-
"https://api.stacspec.org/v1.0.0-rc.1/collection-search#filter"
|
|
79
|
-
)
|
|
80
|
-
|
|
81
76
|
aggregation_extension = AggregationExtension(
|
|
82
77
|
client=EsAsyncBaseAggregationClient(
|
|
83
78
|
database=database_logic, session=session, settings=settings
|
|
@@ -96,7 +91,6 @@ search_extensions = [
|
|
|
96
91
|
TokenPaginationExtension(),
|
|
97
92
|
filter_extension,
|
|
98
93
|
FreeTextExtension(),
|
|
99
|
-
collection_search_extension,
|
|
100
94
|
]
|
|
101
95
|
|
|
102
96
|
if TRANSACTIONS_EXTENSIONS:
|
|
@@ -122,6 +116,27 @@ if TRANSACTIONS_EXTENSIONS:
|
|
|
122
116
|
|
|
123
117
|
extensions = [aggregation_extension] + search_extensions
|
|
124
118
|
|
|
119
|
+
# Create collection search extensions if enabled
|
|
120
|
+
if ENABLE_COLLECTIONS_SEARCH:
|
|
121
|
+
# Create collection search extensions
|
|
122
|
+
collection_search_extensions = [
|
|
123
|
+
# QueryExtension(conformance_classes=[QueryConformanceClasses.COLLECTIONS]),
|
|
124
|
+
SortExtension(conformance_classes=[SortConformanceClasses.COLLECTIONS]),
|
|
125
|
+
FieldsExtension(conformance_classes=[FieldsConformanceClasses.COLLECTIONS]),
|
|
126
|
+
# CollectionSearchFilterExtension(
|
|
127
|
+
# conformance_classes=[FilterConformanceClasses.COLLECTIONS]
|
|
128
|
+
# ),
|
|
129
|
+
FreeTextExtension(conformance_classes=[FreeTextConformanceClasses.COLLECTIONS]),
|
|
130
|
+
]
|
|
131
|
+
|
|
132
|
+
# Initialize collection search with its extensions
|
|
133
|
+
collection_search_ext = CollectionSearchExtension.from_extensions(
|
|
134
|
+
collection_search_extensions
|
|
135
|
+
)
|
|
136
|
+
collections_get_request_model = collection_search_ext.GET
|
|
137
|
+
|
|
138
|
+
extensions.append(collection_search_ext)
|
|
139
|
+
|
|
125
140
|
database_logic.extensions = [type(ext).__name__ for ext in extensions]
|
|
126
141
|
|
|
127
142
|
post_request_model = create_post_request_model(search_extensions)
|
|
@@ -160,6 +175,10 @@ app_config = {
|
|
|
160
175
|
"route_dependencies": get_route_dependencies(),
|
|
161
176
|
}
|
|
162
177
|
|
|
178
|
+
# Add collections_get_request_model if collection search is enabled
|
|
179
|
+
if ENABLE_COLLECTIONS_SEARCH:
|
|
180
|
+
app_config["collections_get_request_model"] = collections_get_request_model
|
|
181
|
+
|
|
163
182
|
api = StacApi(**app_config)
|
|
164
183
|
|
|
165
184
|
|
|
@@ -17,7 +17,7 @@ from starlette.requests import Request
|
|
|
17
17
|
|
|
18
18
|
from stac_fastapi.core.base_database_logic import BaseDatabaseLogic
|
|
19
19
|
from stac_fastapi.core.serializers import CollectionSerializer, ItemSerializer
|
|
20
|
-
from stac_fastapi.core.utilities import bbox2polygon, get_max_limit
|
|
20
|
+
from stac_fastapi.core.utilities import bbox2polygon, get_bool_env, get_max_limit
|
|
21
21
|
from stac_fastapi.elasticsearch.config import AsyncElasticsearchSettings
|
|
22
22
|
from stac_fastapi.elasticsearch.config import (
|
|
23
23
|
ElasticsearchSettings as SyncElasticsearchSettings,
|
|
@@ -170,28 +170,96 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
170
170
|
"""CORE LOGIC"""
|
|
171
171
|
|
|
172
172
|
async def get_all_collections(
|
|
173
|
-
self,
|
|
173
|
+
self,
|
|
174
|
+
token: Optional[str],
|
|
175
|
+
limit: int,
|
|
176
|
+
request: Request,
|
|
177
|
+
sort: Optional[List[Dict[str, Any]]] = None,
|
|
178
|
+
q: Optional[List[str]] = None,
|
|
174
179
|
) -> Tuple[List[Dict[str, Any]], Optional[str]]:
|
|
175
|
-
"""Retrieve a list of
|
|
180
|
+
"""Retrieve a list of collections from Elasticsearch, supporting pagination.
|
|
176
181
|
|
|
177
182
|
Args:
|
|
178
183
|
token (Optional[str]): The pagination token.
|
|
179
184
|
limit (int): The number of results to return.
|
|
185
|
+
request (Request): The FastAPI request object.
|
|
186
|
+
sort (Optional[List[Dict[str, Any]]]): Optional sort parameter from the request.
|
|
187
|
+
q (Optional[List[str]]): Free text search terms.
|
|
180
188
|
|
|
181
189
|
Returns:
|
|
182
190
|
A tuple of (collections, next pagination token if any).
|
|
191
|
+
|
|
192
|
+
Raises:
|
|
193
|
+
HTTPException: If sorting is requested on a field that is not sortable.
|
|
183
194
|
"""
|
|
184
|
-
|
|
195
|
+
# Define sortable fields based on the ES_COLLECTIONS_MAPPINGS
|
|
196
|
+
sortable_fields = ["id", "extent.temporal.interval", "temporal"]
|
|
197
|
+
|
|
198
|
+
# Format the sort parameter
|
|
199
|
+
formatted_sort = []
|
|
200
|
+
if sort:
|
|
201
|
+
for item in sort:
|
|
202
|
+
field = item.get("field")
|
|
203
|
+
direction = item.get("direction", "asc")
|
|
204
|
+
if field:
|
|
205
|
+
# Validate that the field is sortable
|
|
206
|
+
if field not in sortable_fields:
|
|
207
|
+
raise HTTPException(
|
|
208
|
+
status_code=400,
|
|
209
|
+
detail=f"Field '{field}' is not sortable. Sortable fields are: {', '.join(sortable_fields)}. "
|
|
210
|
+
+ "Text fields are not sortable by default in Elasticsearch. "
|
|
211
|
+
+ "To make a field sortable, update the mapping to use 'keyword' type or add a '.keyword' subfield. ",
|
|
212
|
+
)
|
|
213
|
+
formatted_sort.append({field: {"order": direction}})
|
|
214
|
+
# Always include id as a secondary sort to ensure consistent pagination
|
|
215
|
+
if not any("id" in item for item in formatted_sort):
|
|
216
|
+
formatted_sort.append({"id": {"order": "asc"}})
|
|
217
|
+
else:
|
|
218
|
+
formatted_sort = [{"id": {"order": "asc"}}]
|
|
219
|
+
|
|
220
|
+
body = {
|
|
221
|
+
"sort": formatted_sort,
|
|
222
|
+
"size": limit,
|
|
223
|
+
}
|
|
224
|
+
|
|
185
225
|
if token:
|
|
186
|
-
search_after = [token]
|
|
226
|
+
body["search_after"] = [token]
|
|
227
|
+
|
|
228
|
+
# Apply free text query if provided
|
|
229
|
+
if q:
|
|
230
|
+
# For collections, we want to search across all relevant fields
|
|
231
|
+
should_clauses = []
|
|
232
|
+
|
|
233
|
+
# For each search term
|
|
234
|
+
for term in q:
|
|
235
|
+
# Create a multi_match query for each term
|
|
236
|
+
for field in [
|
|
237
|
+
"id",
|
|
238
|
+
"title",
|
|
239
|
+
"description",
|
|
240
|
+
"keywords",
|
|
241
|
+
"summaries.platform",
|
|
242
|
+
"summaries.constellation",
|
|
243
|
+
"providers.name",
|
|
244
|
+
"providers.url",
|
|
245
|
+
]:
|
|
246
|
+
should_clauses.append(
|
|
247
|
+
{
|
|
248
|
+
"wildcard": {
|
|
249
|
+
field: {"value": f"*{term}*", "case_insensitive": True}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
)
|
|
187
253
|
|
|
254
|
+
# Add the query to the body using bool query with should clauses
|
|
255
|
+
body["query"] = {
|
|
256
|
+
"bool": {"should": should_clauses, "minimum_should_match": 1}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
# Execute the search
|
|
188
260
|
response = await self.client.search(
|
|
189
261
|
index=COLLECTIONS_INDEX,
|
|
190
|
-
body=
|
|
191
|
-
"sort": [{"id": {"order": "asc"}}],
|
|
192
|
-
"size": limit,
|
|
193
|
-
**({"search_after": search_after} if search_after is not None else {}),
|
|
194
|
-
},
|
|
262
|
+
body=body,
|
|
195
263
|
)
|
|
196
264
|
|
|
197
265
|
hits = response["hits"]["hits"]
|
|
@@ -204,7 +272,9 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
204
272
|
|
|
205
273
|
next_token = None
|
|
206
274
|
if len(hits) == limit:
|
|
207
|
-
|
|
275
|
+
next_token_values = hits[-1].get("sort")
|
|
276
|
+
if next_token_values:
|
|
277
|
+
next_token = next_token_values[0]
|
|
208
278
|
|
|
209
279
|
return collections, next_token
|
|
210
280
|
|
|
@@ -289,26 +359,99 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
289
359
|
Returns:
|
|
290
360
|
The filtered search object.
|
|
291
361
|
"""
|
|
362
|
+
# USE_DATETIME env var
|
|
363
|
+
# True: Search by datetime, if null search by start/end datetime
|
|
364
|
+
# False: Always search only by start/end datetime
|
|
365
|
+
USE_DATETIME = get_bool_env("USE_DATETIME", default=True)
|
|
366
|
+
|
|
292
367
|
datetime_search = return_date(datetime)
|
|
293
368
|
|
|
294
369
|
if not datetime_search:
|
|
295
370
|
return search, datetime_search
|
|
296
371
|
|
|
297
|
-
if
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
372
|
+
if USE_DATETIME:
|
|
373
|
+
if "eq" in datetime_search:
|
|
374
|
+
# For exact matches, include:
|
|
375
|
+
# 1. Items with matching exact datetime
|
|
376
|
+
# 2. Items with datetime:null where the time falls within their range
|
|
377
|
+
should = [
|
|
378
|
+
Q(
|
|
379
|
+
"bool",
|
|
380
|
+
filter=[
|
|
381
|
+
Q("exists", field="properties.datetime"),
|
|
382
|
+
Q(
|
|
383
|
+
"term",
|
|
384
|
+
**{"properties__datetime": datetime_search["eq"]},
|
|
385
|
+
),
|
|
386
|
+
],
|
|
387
|
+
),
|
|
388
|
+
Q(
|
|
389
|
+
"bool",
|
|
390
|
+
must_not=[Q("exists", field="properties.datetime")],
|
|
391
|
+
filter=[
|
|
392
|
+
Q("exists", field="properties.start_datetime"),
|
|
393
|
+
Q("exists", field="properties.end_datetime"),
|
|
394
|
+
Q(
|
|
395
|
+
"range",
|
|
396
|
+
properties__start_datetime={
|
|
397
|
+
"lte": datetime_search["eq"]
|
|
398
|
+
},
|
|
399
|
+
),
|
|
400
|
+
Q(
|
|
401
|
+
"range",
|
|
402
|
+
properties__end_datetime={"gte": datetime_search["eq"]},
|
|
403
|
+
),
|
|
404
|
+
],
|
|
405
|
+
),
|
|
406
|
+
]
|
|
407
|
+
else:
|
|
408
|
+
# For date ranges, include:
|
|
409
|
+
# 1. Items with datetime in the range
|
|
410
|
+
# 2. Items with datetime:null that overlap the search range
|
|
411
|
+
should = [
|
|
412
|
+
Q(
|
|
413
|
+
"bool",
|
|
414
|
+
filter=[
|
|
415
|
+
Q("exists", field="properties.datetime"),
|
|
416
|
+
Q(
|
|
417
|
+
"range",
|
|
418
|
+
properties__datetime={
|
|
419
|
+
"gte": datetime_search["gte"],
|
|
420
|
+
"lte": datetime_search["lte"],
|
|
421
|
+
},
|
|
422
|
+
),
|
|
423
|
+
],
|
|
424
|
+
),
|
|
425
|
+
Q(
|
|
426
|
+
"bool",
|
|
427
|
+
must_not=[Q("exists", field="properties.datetime")],
|
|
428
|
+
filter=[
|
|
429
|
+
Q("exists", field="properties.start_datetime"),
|
|
430
|
+
Q("exists", field="properties.end_datetime"),
|
|
431
|
+
Q(
|
|
432
|
+
"range",
|
|
433
|
+
properties__start_datetime={
|
|
434
|
+
"lte": datetime_search["lte"]
|
|
435
|
+
},
|
|
436
|
+
),
|
|
437
|
+
Q(
|
|
438
|
+
"range",
|
|
439
|
+
properties__end_datetime={
|
|
440
|
+
"gte": datetime_search["gte"]
|
|
441
|
+
},
|
|
442
|
+
),
|
|
443
|
+
],
|
|
444
|
+
),
|
|
445
|
+
]
|
|
446
|
+
|
|
447
|
+
return (
|
|
448
|
+
search.query(Q("bool", should=should, minimum_should_match=1)),
|
|
449
|
+
datetime_search,
|
|
450
|
+
)
|
|
451
|
+
else:
|
|
452
|
+
if "eq" in datetime_search:
|
|
453
|
+
filter_query = Q(
|
|
310
454
|
"bool",
|
|
311
|
-
must_not=[Q("exists", field="properties.datetime")],
|
|
312
455
|
filter=[
|
|
313
456
|
Q("exists", field="properties.start_datetime"),
|
|
314
457
|
Q("exists", field="properties.end_datetime"),
|
|
@@ -321,29 +464,10 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
321
464
|
properties__end_datetime={"gte": datetime_search["eq"]},
|
|
322
465
|
),
|
|
323
466
|
],
|
|
324
|
-
)
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
# For date ranges, include:
|
|
328
|
-
# 1. Items with datetime in the range
|
|
329
|
-
# 2. Items with datetime:null that overlap the search range
|
|
330
|
-
should = [
|
|
331
|
-
Q(
|
|
332
|
-
"bool",
|
|
333
|
-
filter=[
|
|
334
|
-
Q("exists", field="properties.datetime"),
|
|
335
|
-
Q(
|
|
336
|
-
"range",
|
|
337
|
-
properties__datetime={
|
|
338
|
-
"gte": datetime_search["gte"],
|
|
339
|
-
"lte": datetime_search["lte"],
|
|
340
|
-
},
|
|
341
|
-
),
|
|
342
|
-
],
|
|
343
|
-
),
|
|
344
|
-
Q(
|
|
467
|
+
)
|
|
468
|
+
else:
|
|
469
|
+
filter_query = Q(
|
|
345
470
|
"bool",
|
|
346
|
-
must_not=[Q("exists", field="properties.datetime")],
|
|
347
471
|
filter=[
|
|
348
472
|
Q("exists", field="properties.start_datetime"),
|
|
349
473
|
Q("exists", field="properties.end_datetime"),
|
|
@@ -356,13 +480,8 @@ class DatabaseLogic(BaseDatabaseLogic):
|
|
|
356
480
|
properties__end_datetime={"gte": datetime_search["gte"]},
|
|
357
481
|
),
|
|
358
482
|
],
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return (
|
|
363
|
-
search.query(Q("bool", should=should, minimum_should_match=1)),
|
|
364
|
-
datetime_search,
|
|
365
|
-
)
|
|
483
|
+
)
|
|
484
|
+
return search.query(filter_query), datetime_search
|
|
366
485
|
|
|
367
486
|
@staticmethod
|
|
368
487
|
def apply_bbox_filter(search: Search, bbox: List):
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""library version."""
|
|
2
|
-
__version__ = "6.
|
|
2
|
+
__version__ = "6.4.0"
|
{stac_fastapi_elasticsearch-6.3.0.dist-info → stac_fastapi_elasticsearch-6.4.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: stac-fastapi-elasticsearch
|
|
3
|
-
Version: 6.
|
|
3
|
+
Version: 6.4.0
|
|
4
4
|
Summary: An implementation of STAC API based on the FastAPI framework with both Elasticsearch and Opensearch.
|
|
5
5
|
Home-page: https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch
|
|
6
6
|
License: MIT
|
|
@@ -15,8 +15,8 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
15
15
|
Classifier: License :: OSI Approved :: MIT License
|
|
16
16
|
Requires-Python: >=3.9
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
|
-
Requires-Dist: stac-fastapi-core==6.
|
|
19
|
-
Requires-Dist: sfeos-helpers==6.
|
|
18
|
+
Requires-Dist: stac-fastapi-core==6.4.0
|
|
19
|
+
Requires-Dist: sfeos-helpers==6.4.0
|
|
20
20
|
Requires-Dist: elasticsearch[async]~=8.18.0
|
|
21
21
|
Requires-Dist: uvicorn~=0.23.0
|
|
22
22
|
Requires-Dist: starlette<0.36.0,>=0.35.0
|
|
@@ -72,11 +72,10 @@ SFEOS (stac-fastapi-elasticsearch-opensearch) is a high-performance, scalable AP
|
|
|
72
72
|
- **Scale to millions of geospatial assets** with fast search performance through optimized spatial indexing and query capabilities
|
|
73
73
|
- **Support OGC-compliant filtering** including spatial operations (intersects, contains, etc.) and temporal queries
|
|
74
74
|
- **Perform geospatial aggregations** to analyze data distribution across space and time
|
|
75
|
+
- **Enhanced collection search capabilities** with support for sorting and field selection
|
|
75
76
|
|
|
76
77
|
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.
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
79
|
## Common Deployment Patterns
|
|
81
80
|
|
|
82
81
|
stac-fastapi-elasticsearch-opensearch can be deployed in several ways depending on your needs:
|
|
@@ -108,6 +107,7 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
108
107
|
- [Common Deployment Patterns](#common-deployment-patterns)
|
|
109
108
|
- [Technologies](#technologies)
|
|
110
109
|
- [Table of Contents](#table-of-contents)
|
|
110
|
+
- [Collection Search Extensions](#collection-search-extensions)
|
|
111
111
|
- [Documentation \& Resources](#documentation--resources)
|
|
112
112
|
- [Package Structure](#package-structure)
|
|
113
113
|
- [Examples](#examples)
|
|
@@ -149,6 +149,37 @@ This project is built on the following technologies: STAC, stac-fastapi, FastAPI
|
|
|
149
149
|
- [Gitter Chat](https://app.gitter.im/#/room/#stac-fastapi-elasticsearch_community:gitter.im) - For real-time discussions
|
|
150
150
|
- [GitHub Discussions](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/discussions) - For longer-form questions and answers
|
|
151
151
|
|
|
152
|
+
## Collection Search Extensions
|
|
153
|
+
|
|
154
|
+
SFEOS implements extended capabilities for the `/collections` endpoint, allowing for more powerful collection discovery:
|
|
155
|
+
|
|
156
|
+
- **Sorting**: Sort collections by sortable fields using the `sortby` parameter
|
|
157
|
+
- Example: `/collections?sortby=+id` (ascending sort by ID)
|
|
158
|
+
- Example: `/collections?sortby=-id` (descending sort by ID)
|
|
159
|
+
- Example: `/collections?sortby=-temporal` (descending sort by temporal extent)
|
|
160
|
+
|
|
161
|
+
- **Field Selection**: Request only specific fields to be returned using the `fields` parameter
|
|
162
|
+
- Example: `/collections?fields=id,title,description`
|
|
163
|
+
- This helps reduce payload size when only certain fields are needed
|
|
164
|
+
|
|
165
|
+
- **Free Text Search**: Search across collection text fields using the `q` parameter
|
|
166
|
+
- Example: `/collections?q=landsat`
|
|
167
|
+
- Searches across multiple text fields including title, description, and keywords
|
|
168
|
+
- Supports partial word matching and relevance-based sorting
|
|
169
|
+
|
|
170
|
+
These extensions make it easier to build user interfaces that display and navigate through collections efficiently.
|
|
171
|
+
|
|
172
|
+
> **Configuration**: Collection search extensions can be disabled by setting the `ENABLE_COLLECTIONS_SEARCH` environment variable to `false`. By default, these extensions are enabled.
|
|
173
|
+
|
|
174
|
+
> **Note**: Sorting is only available on fields that are indexed for sorting in Elasticsearch/OpenSearch. With the default mappings, you can sort on:
|
|
175
|
+
> - `id` (keyword field)
|
|
176
|
+
> - `extent.temporal.interval` (date field)
|
|
177
|
+
> - `temporal` (alias to extent.temporal.interval)
|
|
178
|
+
>
|
|
179
|
+
> 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.
|
|
180
|
+
>
|
|
181
|
+
> **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.
|
|
182
|
+
|
|
152
183
|
## Package Structure
|
|
153
184
|
|
|
154
185
|
This project is organized into several packages, each with a specific purpose:
|
|
@@ -279,10 +310,12 @@ You can customize additional settings in your `.env` file:
|
|
|
279
310
|
| `ENABLE_DIRECT_RESPONSE` | Enable direct response for maximum performance (disables all FastAPI dependencies, including authentication, custom status codes, and validation) | `false` | Optional |
|
|
280
311
|
| `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 |
|
|
281
312
|
| `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 |
|
|
313
|
+
| `ENABLE_COLLECTIONS_SEARCH` | Enable collection search extensions (sort, fields). | `true` | Optional |
|
|
282
314
|
| `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 |
|
|
283
315
|
| `STAC_ITEM_LIMIT` | Sets the environment variable for result limiting to SFEOS for the number of returned items and STAC collections. | `10` | Optional |
|
|
284
316
|
| `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 |
|
|
285
317
|
| `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 |
|
|
318
|
+
| `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 |
|
|
286
319
|
|
|
287
320
|
> [!NOTE]
|
|
288
321
|
> 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.
|
|
@@ -424,6 +457,10 @@ The system uses a precise naming convention:
|
|
|
424
457
|
- **Root Path Configuration**: The application root path is the base URL by default.
|
|
425
458
|
- For AWS Lambda with Gateway API: Set `STAC_FASTAPI_ROOT_PATH` to match the Gateway API stage name (e.g., `/v1`)
|
|
426
459
|
|
|
460
|
+
- **Feature Configuration**: Control which features are enabled:
|
|
461
|
+
- `ENABLE_COLLECTIONS_SEARCH`: Set to `true` (default) to enable collection search extensions (sort, fields). Set to `false` to disable.
|
|
462
|
+
- `ENABLE_TRANSACTIONS_EXTENSIONS`: Set to `true` (default) to enable transaction extensions. Set to `false` to disable.
|
|
463
|
+
|
|
427
464
|
|
|
428
465
|
## Collection Pagination
|
|
429
466
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
stac_fastapi/elasticsearch/__init__.py,sha256=w_MZutYLreNV372sCuO46bPb0TngmPs4u8737ueS0wE,31
|
|
2
|
+
stac_fastapi/elasticsearch/app.py,sha256=BXoewlnMDHU6bwBJY9bV02Gho-ZzmIyESMOUWPMuR9k,7506
|
|
3
|
+
stac_fastapi/elasticsearch/config.py,sha256=itvPYr4TiOg9pWQrycgGaQxQ_Vc2KKP3aHdtH0OUZvw,5322
|
|
4
|
+
stac_fastapi/elasticsearch/database_logic.py,sha256=6dvex-sEMsl3rBnfTKYey7gyG63wq6KPzOUYRM20r4I,63574
|
|
5
|
+
stac_fastapi/elasticsearch/version.py,sha256=1xfRb7s1Stv055oEewNJpZn9OQUUcaJvgSzCsYLHYSQ,45
|
|
6
|
+
stac_fastapi_elasticsearch-6.4.0.dist-info/METADATA,sha256=-kQ6Zw1DMLH7WOvdtMCqsWbrC7HxnZ1Jp9xPVpJrqg0,39686
|
|
7
|
+
stac_fastapi_elasticsearch-6.4.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
8
|
+
stac_fastapi_elasticsearch-6.4.0.dist-info/entry_points.txt,sha256=aCKixki0LpUl64UPsPMtiNvfdyq-QsTCxVjJ54VF6Jk,82
|
|
9
|
+
stac_fastapi_elasticsearch-6.4.0.dist-info/top_level.txt,sha256=vqn-D9-HsRPTTxy0Vk_KkDmTiMES4owwBQ3ydSZYb2s,13
|
|
10
|
+
stac_fastapi_elasticsearch-6.4.0.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
stac_fastapi/elasticsearch/__init__.py,sha256=w_MZutYLreNV372sCuO46bPb0TngmPs4u8737ueS0wE,31
|
|
2
|
-
stac_fastapi/elasticsearch/app.py,sha256=42586pNMswKIyC-Q9Lz3hJh88Gm60ibbOsBOpbD0x50,6579
|
|
3
|
-
stac_fastapi/elasticsearch/config.py,sha256=itvPYr4TiOg9pWQrycgGaQxQ_Vc2KKP3aHdtH0OUZvw,5322
|
|
4
|
-
stac_fastapi/elasticsearch/database_logic.py,sha256=M6xIgtl3HB9p2V6wZPB6xm6cY02iYa2oG2OJRUbpA0c,58488
|
|
5
|
-
stac_fastapi/elasticsearch/version.py,sha256=rBLPQyvMDNA0PA0jXfByTouJPJn5p0wXiqmUWJMIfYc,45
|
|
6
|
-
stac_fastapi_elasticsearch-6.3.0.dist-info/METADATA,sha256=ijEkw05ul0-pg5rRfPMG0oKnXQd2iRNzvaIW4J4cSBo,36626
|
|
7
|
-
stac_fastapi_elasticsearch-6.3.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
8
|
-
stac_fastapi_elasticsearch-6.3.0.dist-info/entry_points.txt,sha256=aCKixki0LpUl64UPsPMtiNvfdyq-QsTCxVjJ54VF6Jk,82
|
|
9
|
-
stac_fastapi_elasticsearch-6.3.0.dist-info/top_level.txt,sha256=vqn-D9-HsRPTTxy0Vk_KkDmTiMES4owwBQ3ydSZYb2s,13
|
|
10
|
-
stac_fastapi_elasticsearch-6.3.0.dist-info/RECORD,,
|
{stac_fastapi_elasticsearch-6.3.0.dist-info → stac_fastapi_elasticsearch-6.4.0.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|