@@ -170,18 +170,12 @@ def indices(collection_ids: Optional[List[str]]) -> str:
170170
171171
172172async 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