Skip to content

Commit 712004e

Browse files
author
Grzegorz Pustulka
committed
docs
1 parent 1fd2551 commit 712004e

File tree

12 files changed

+57
-31
lines changed

12 files changed

+57
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ You can customize additional settings in your `.env` file:
225225
| `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 |
226226
| `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 |
227227
| `ENABLE_DATETIME_INDEX_FILTERING` | Enable datetime-based index selection using collection IDs. Requires indexes in format: STAC_ITEMS_INDEX_PREFIX_collection-id_start_year-start_month-start_day-end_year-end_month-end_day, e.g. items_sentinel-2-l2a_2025-06-06-2025-09-22. | `false` | Optional |
228-
| `DATETIME_INDEX_MAX_SIZE_GB` | Maximum size limit in GB for datetime-based indexes. When an index exceeds this size, a new time-partitioned index will be created. Only applies when `ENABLE_DATETIME_INDEX_FILTERING` is enabled. | `25` | Optional |
228+
| `DATETIME_INDEX_MAX_SIZE_GB` | Maximum size limit in GB for datetime-based indexes. When an index exceeds this size, a new time-partitioned index will be created. Note: This value should account for ~25% overhead due to OS/ES caching of data structures and metadata. Only applies when`ENABLE_DATETIME_INDEX_FILTERING` is enabled. | `25` | Optional |
229229

230230

231231
> [!NOTE]

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/database/document.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
including document ID generation and bulk action creation.
55
"""
66

7-
from stac_fastapi.sfeos_helpers.database.index import index_alias_by_collection_id
8-
97

108
def mk_item_id(item_id: str, collection_id: str) -> str:
119
"""Create the document id for an Item in Elasticsearch.

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/database/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from functools import lru_cache
88
from typing import Any, List, Optional
99

10-
from dateutil.parser import parse
10+
from dateutil.parser import parse # type: ignore[import]
1111

1212
from stac_fastapi.sfeos_helpers.mappings import (
1313
_ES_INDEX_NAME_UNSUPPORTED_CHARS_TABLE,

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/adapters.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ def create_datetime_index_sync(
7878
"""
7979
pass
8080

81-
async def update_index_alias(
82-
self, client: Any, end_date: str, old_alias: str
83-
) -> str:
81+
@staticmethod
82+
async def update_index_alias(client: Any, end_date: str, old_alias: str) -> str:
8483
"""Update index alias with new end date.
8584
8685
Args:
@@ -104,9 +103,8 @@ async def update_index_alias(
104103
)
105104
return new_alias
106105

107-
def update_index_alias_sync(
108-
self, client: Any, end_date: str, old_alias: str
109-
) -> str:
106+
@staticmethod
107+
def update_index_alias_sync(client: Any, end_date: str, old_alias: str) -> str:
110108
"""Update index alias synchronously.
111109
112110
Args:
@@ -236,7 +234,8 @@ def create_datetime_index_sync(
236234
class OpenSearchAdapter(SearchEngineAdapter):
237235
"""OpenSearch-specific adapter implementation."""
238236

239-
def _create_index_body(self, aliases: Dict[str, Dict]) -> Dict[str, Any]:
237+
@staticmethod
238+
def _create_index_body(aliases: Dict[str, Dict]) -> Dict[str, Any]:
240239
"""Create index body with common settings.
241240
242241
Args:

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/async_inserters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ async def _get_target_index_internal(
9696
product: Dict[str, Any],
9797
check_size: bool = True,
9898
) -> str:
99-
"""Internal method to get target index with size checking.
99+
"""Get target index with size checking internally.
100100
101101
Args:
102102
index_selector: Index selector instance.

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/base.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,39 @@
11
"""Base classes for index inserters."""
22

33
from abc import ABC, abstractmethod
4-
from typing import Any, Dict, List
4+
from typing import Any, Awaitable, Dict, List, Union
55

66

77
class BaseIndexInserter(ABC):
88
"""Base class for index insertion strategies."""
99

1010
@abstractmethod
11-
def get_target_index(self, collection_id: str, product: Dict[str, Any]) -> str:
11+
def get_target_index(
12+
self, collection_id: str, product: Dict[str, Any]
13+
) -> Union[str, Awaitable[str]]:
1214
"""Get target index for a product.
1315
1416
Args:
1517
collection_id (str): Collection identifier.
1618
product (Dict[str, Any]): Product data.
1719
1820
Returns:
19-
str: Target index name.
21+
Union[str, Awaitable[str]]: Target index name or awaitable.
2022
"""
2123
pass
2224

2325
@abstractmethod
2426
def prepare_bulk_actions(
2527
self, collection_id: str, items: List[Dict[str, Any]]
26-
) -> List[Dict[str, Any]]:
28+
) -> Union[List[Dict[str, Any]], Awaitable[List[Dict[str, Any]]]]:
2729
"""Prepare bulk actions for multiple items.
2830
2931
Args:
3032
collection_id (str): Collection identifier.
3133
items (List[Dict[str, Any]]): List of items to process.
3234
3335
Returns:
34-
List[Dict[str, Any]]: List of bulk actions.
36+
Union[List[Dict[str, Any]], Awaitable[List[Dict[str, Any]]]]: List of bulk actions or awaitable.
3537
"""
3638
pass
3739

@@ -78,6 +80,7 @@ async def prepare_bulk_actions(
7880
"""
7981
pass
8082

83+
@abstractmethod
8184
async def create_simple_index(self, client: Any, collection_id: str) -> str:
8285
"""Create a simple index asynchronously.
8386
@@ -94,6 +97,35 @@ async def create_simple_index(self, client: Any, collection_id: str) -> str:
9497
class BaseSyncIndexInserter(BaseIndexInserter):
9598
"""Base sync index inserter with common sync methods."""
9699

100+
@abstractmethod
101+
def get_target_index(self, collection_id: str, product: Dict[str, Any]) -> str:
102+
"""Get target index for a product synchronously.
103+
104+
Args:
105+
collection_id (str): Collection identifier.
106+
product (Dict[str, Any]): Product data.
107+
108+
Returns:
109+
str: Target index name.
110+
"""
111+
pass
112+
113+
@abstractmethod
114+
def prepare_bulk_actions(
115+
self, collection_id: str, items: List[Dict[str, Any]]
116+
) -> List[Dict[str, Any]]:
117+
"""Prepare bulk actions for multiple items synchronously.
118+
119+
Args:
120+
collection_id (str): Collection identifier.
121+
items (List[Dict[str, Any]]): List of items to process.
122+
123+
Returns:
124+
List[Dict[str, Any]]: List of bulk actions.
125+
"""
126+
pass
127+
128+
@abstractmethod
97129
def create_simple_index(self, client: Any, collection_id: str) -> str:
98130
"""Create a simple index synchronously.
99131

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/managers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(self, client: Any):
2424
client: Search engine client instance.
2525
"""
2626
self.client = client
27-
self.max_size_gb = float(os.getenv("DATETIME_INDEX_MAX_SIZE_GB", "20"))
27+
self.max_size_gb = float(os.getenv("DATETIME_INDEX_MAX_SIZE_GB", "25"))
2828

2929
async def get_index_size_in_gb(self, index_name: str) -> float:
3030
"""Get index size in gigabytes asynchronously.
@@ -89,7 +89,8 @@ def __init__(self, client: Any, search_adapter: SearchEngineAdapter):
8989
self.search_adapter = search_adapter
9090
self.size_manager = IndexSizeManager(client)
9191

92-
def _validate_product_datetime(self, product: Dict[str, Any]) -> str:
92+
@staticmethod
93+
def _validate_product_datetime(product: Dict[str, Any]) -> str:
9394
"""Validate and extract datetime from product.
9495
9596
Args:

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/selection/cache_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async def load_aliases(self) -> Dict[str, List[str]]:
7474
Dict[str, List[str]]: Mapping of base aliases to item aliases.
7575
"""
7676
response = await self.client.indices.get_alias(index=f"{ITEMS_INDEX_PREFIX}*")
77-
result = {}
77+
result: Dict[str, List[str]] = {}
7878

7979
for index_info in response.values():
8080
aliases = index_info.get("aliases", {})
@@ -145,7 +145,7 @@ def load_aliases(self) -> Dict[str, List[str]]:
145145
Dict[str, List[str]]: Mapping of base aliases to item aliases.
146146
"""
147147
response = self.client.indices.get_alias(index=f"{ITEMS_INDEX_PREFIX}*")
148-
result = {}
148+
result: Dict[str, List[str]] = {}
149149

150150
for index_info in response.values():
151151
aliases = index_info.get("aliases", {})

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/selection/unfiltered_selector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class UnfilteredIndexSelector(IndexSelectionStrategy):
1111
"""Index selector that returns all available indices without filtering."""
1212

13-
def select_indexes(
13+
async def select_indexes(
1414
self,
1515
collection_ids: Optional[List[str]],
1616
datetime_search: Dict[str, Optional[str]],

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/search_engine/sync_inserters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _get_target_index_internal(
9292
product: Dict[str, Any],
9393
check_size: bool = True,
9494
) -> str:
95-
"""Internal method to get target index with size checking.
95+
"""Get target index with size checking internally.
9696
9797
Args:
9898
index_selector: Index selector instance.

0 commit comments

Comments
 (0)