Skip to content

Commit eb586c6

Browse files
committed
ues options
1 parent 05423b5 commit eb586c6

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,12 @@ def indices(collection_ids: Optional[List[str]]) -> str:
170170

171171

172172
async def create_collection_index() -> None:
173-
"""Create the index for Collections in Elasticsearch.
174-
175-
This function creates the Elasticsearch index for the `Collections` with the predefined mapping.
176-
If the index already exists, the function ignores the error and continues execution.
177-
"""
178173
client = AsyncElasticsearchSettings().create_client
179174

180-
await client.indices.create(
175+
await client.options(ignore_status=400).indices.create(
181176
index=f"{COLLECTIONS_INDEX}-000001",
182177
aliases={COLLECTIONS_INDEX: {}},
183-
mappings=ES_COLLECTIONS_MAPPINGS,
184-
ignore=400, # ignore 400 already exists code
178+
mappings=ES_COLLECTIONS_MAPPINGS
185179
)
186180
await client.close()
187181

@@ -200,12 +194,11 @@ async def create_item_index(collection_id: str):
200194
client = AsyncElasticsearchSettings().create_client
201195
index_name = index_by_collection_id(collection_id)
202196

203-
await client.indices.create(
197+
await client.options(ignore_status=400).indices.create(
204198
index=f"{index_by_collection_id(collection_id)}-000001",
205199
aliases={index_name: {}},
206200
mappings=ES_ITEMS_MAPPINGS,
207201
settings=ES_ITEMS_SETTINGS,
208-
ignore=400, # ignore 400 already exists code
209202
)
210203
await client.close()
211204

0 commit comments

Comments
 (0)