@@ -170,18 +170,12 @@ def indices(collection_ids: Optional[List[str]]) -> str:
170
170
171
171
172
172
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
- """
178
173
client = AsyncElasticsearchSettings ().create_client
179
174
180
- await client .indices .create (
175
+ await client .options ( ignore_status = 400 ). indices .create (
181
176
index = f"{ COLLECTIONS_INDEX } -000001" ,
182
177
aliases = {COLLECTIONS_INDEX : {}},
183
- mappings = ES_COLLECTIONS_MAPPINGS ,
184
- ignore = 400 , # ignore 400 already exists code
178
+ mappings = ES_COLLECTIONS_MAPPINGS
185
179
)
186
180
await client .close ()
187
181
@@ -200,12 +194,11 @@ async def create_item_index(collection_id: str):
200
194
client = AsyncElasticsearchSettings ().create_client
201
195
index_name = index_by_collection_id (collection_id )
202
196
203
- await client .indices .create (
197
+ await client .options ( ignore_status = 400 ). indices .create (
204
198
index = f"{ index_by_collection_id (collection_id )} -000001" ,
205
199
aliases = {index_name : {}},
206
200
mappings = ES_ITEMS_MAPPINGS ,
207
201
settings = ES_ITEMS_SETTINGS ,
208
- ignore = 400 , # ignore 400 already exists code
209
202
)
210
203
await client .close ()
211
204
0 commit comments