Skip to content

Commit 256f52b

Browse files
author
Grzegorz Pustulka
committed
refactoring
1 parent 738e6e0 commit 256f52b

File tree

23 files changed

+1335
-1244
lines changed

23 files changed

+1335
-1244
lines changed

compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ services:
9191
- discovery.type=single-node
9292
- plugins.security.disabled=true
9393
- OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
94+
- action.destructive_requires_name=false
9495
volumes:
9596
- ./opensearch/config/opensearch.yml:/usr/share/opensearch/config/opensearch.yml
9697
- ./opensearch/snapshots:/usr/share/opensearch/snapshots

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
)
2323
from stac_fastapi.sfeos_helpers import filter
2424
from stac_fastapi.sfeos_helpers.database import (
25-
AsyncIndexInserter,
26-
IndexInsertionFactory,
27-
IndexSelectionStrategy,
28-
IndexSelectorFactory,
29-
SyncIndexInserter,
3025
apply_free_text_filter_shared,
3126
apply_intersects_filter_shared,
3227
create_index_templates_shared,
@@ -40,6 +35,12 @@
4035
return_date,
4136
validate_refresh,
4237
)
38+
from stac_fastapi.sfeos_helpers.search_engine import (
39+
BaseIndexInserter,
40+
IndexInsertionFactory,
41+
IndexSelectionStrategy,
42+
IndexSelectorFactory,
43+
)
4344
from stac_fastapi.sfeos_helpers.mappings import (
4445
AGGREGATION_MAPPING,
4546
COLLECTIONS_INDEX,
@@ -128,8 +129,8 @@ class DatabaseLogic(BaseDatabaseLogic):
128129
)
129130
async_index_selector: IndexSelectionStrategy = attr.ib(init=False)
130131
sync_index_selector: IndexSelectionStrategy = attr.ib(init=False)
131-
async_index_inserter: AsyncIndexInserter = attr.ib(init=False)
132-
sync_index_inserter: SyncIndexInserter = attr.ib(init=False)
132+
async_index_inserter: BaseIndexInserter = attr.ib(init=False)
133+
sync_index_inserter: BaseIndexInserter = attr.ib(init=False)
133134

134135
client = attr.ib(init=False)
135136
sync_client = attr.ib(init=False)
@@ -138,7 +139,7 @@ def __attrs_post_init__(self):
138139
"""Initialize clients after the class is instantiated."""
139140
self.client = self.async_settings.create_client
140141
self.sync_client = self.sync_settings.create_client
141-
self.async_index_inserter = IndexInsertionFactory.create_insertion_strategy(
142+
self.async_index_inserter = IndexInsertionFactory.create_async_insertion_strategy(
142143
self.client
143144
)
144145
self.sync_index_inserter = IndexInsertionFactory.create_sync_insertion_strategy(

stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
from stac_fastapi.opensearch.config import OpensearchSettings as SyncSearchSettings
2323
from stac_fastapi.sfeos_helpers import filter
2424
from stac_fastapi.sfeos_helpers.database import (
25-
AsyncIndexInserter,
26-
IndexInsertionFactory,
27-
IndexSelectionStrategy,
28-
IndexSelectorFactory,
29-
SyncIndexInserter,
3025
apply_free_text_filter_shared,
3126
apply_intersects_filter_shared,
3227
create_index_templates_shared,
@@ -40,6 +35,12 @@
4035
return_date,
4136
validate_refresh,
4237
)
38+
from stac_fastapi.sfeos_helpers.search_engine import (
39+
BaseIndexInserter,
40+
IndexInsertionFactory,
41+
IndexSelectionStrategy,
42+
IndexSelectorFactory,
43+
)
4344
from stac_fastapi.sfeos_helpers.mappings import (
4445
AGGREGATION_MAPPING,
4546
COLLECTIONS_INDEX,
@@ -115,8 +116,8 @@ class DatabaseLogic(BaseDatabaseLogic):
115116

116117
async_index_selector: IndexSelectionStrategy = attr.ib(init=False)
117118
sync_index_selector: IndexSelectionStrategy = attr.ib(init=False)
118-
async_index_inserter: AsyncIndexInserter = attr.ib(init=False)
119-
sync_index_inserter: SyncIndexInserter = attr.ib(init=False)
119+
async_index_inserter: BaseIndexInserter = attr.ib(init=False)
120+
sync_index_inserter: BaseIndexInserter = attr.ib(init=False)
120121

121122
client = attr.ib(init=False)
122123
sync_client = attr.ib(init=False)
@@ -125,7 +126,7 @@ def __attrs_post_init__(self):
125126
"""Initialize clients after the class is instantiated."""
126127
self.client = self.async_settings.create_client
127128
self.sync_client = self.sync_settings.create_client
128-
self.async_index_inserter = IndexInsertionFactory.create_insertion_strategy(
129+
self.async_index_inserter = IndexInsertionFactory.create_async_insertion_strategy(
129130
self.client
130131
)
131132
self.sync_index_inserter = IndexInsertionFactory.create_sync_insertion_strategy(
@@ -1068,7 +1069,13 @@ async def delete_collection(self, collection_id: str, **kwargs: Any):
10681069
await self.client.delete(
10691070
index=COLLECTIONS_INDEX, id=collection_id, refresh=refresh
10701071
)
1071-
await delete_item_index(collection_id)
1072+
# Delete the item index for the collection
1073+
try:
1074+
await delete_item_index(collection_id)
1075+
except Exception as e:
1076+
logger.error(
1077+
f"Failed to delete item index for collection {collection_id}: {e}"
1078+
)
10721079

10731080
async def bulk_async(
10741081
self,

stac_fastapi/sfeos_helpers/stac_fastapi/sfeos_helpers/database/__init__.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,6 @@
4040
index_by_collection_id,
4141
indices,
4242
)
43-
from .index_insertion_strategies import (
44-
AsyncIndexInserter,
45-
AsyncSimpleIndexInsertion,
46-
BaseIndexInserter,
47-
ElasticsearchAdapter,
48-
IndexInsertionFactory,
49-
OpenSearchAdapter,
50-
SearchEngineAdapter,
51-
SearchEngineAdapterFactory,
52-
SearchEngineType,
53-
SyncIndexInserter,
54-
SyncSimpleIndexInsertion,
55-
)
56-
from .index_selection_strategies import (
57-
AsyncDatetimeBasedIndexSelector,
58-
IndexSelectionStrategy,
59-
IndexSelectorFactory,
60-
SyncDatetimeBasedIndexSelector,
61-
UnfilteredIndexSelector,
62-
)
6343
from .mapping import get_queryables_mapping_shared
6444
from .query import (
6545
apply_free_text_filter_shared,
@@ -76,24 +56,6 @@
7656
"index_by_collection_id",
7757
"filter_indexes_by_datetime",
7858
"indices",
79-
# Index selection strategies
80-
"IndexSelectionStrategy",
81-
"IndexSelectorFactory",
82-
"UnfilteredIndexSelector",
83-
"SyncDatetimeBasedIndexSelector",
84-
"AsyncDatetimeBasedIndexSelector",
85-
# Index insertion strategies
86-
"AsyncIndexInserter",
87-
"AsyncSimpleIndexInsertion",
88-
"BaseIndexInserter",
89-
"ElasticsearchAdapter",
90-
"IndexInsertionFactory",
91-
"OpenSearchAdapter",
92-
"SearchEngineAdapter",
93-
"SearchEngineAdapterFactory",
94-
"SearchEngineType",
95-
"SyncIndexInserter",
96-
"SyncSimpleIndexInsertion",
9759
# Query operations
9860
"apply_free_text_filter_shared",
9961
"apply_intersects_filter_shared",

0 commit comments

Comments
 (0)