File tree Expand file tree Collapse file tree 3 files changed +35
-12
lines changed
stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic Expand file tree Collapse file tree 3 files changed +35
-12
lines changed Original file line number Diff line number Diff line change @@ -59,13 +59,17 @@ test:
5959
6060.PHONY : test-opensearch
6161test-opensearch :
62- -$(run_os ) /bin/bash -c ' export && ./scripts/wait-for-it-es.sh opensearch:9202 && cd /app/stac_fastapi/elasticsearch/tests/clients && pytest'
62+ -$(run_os ) /bin/bash -c ' export && ./scripts/wait-for-it-es.sh opensearch:9202 && cd /app/stac_fastapi/elasticsearch/tests/ && pytest'
6363 docker-compose down
6464
65- .PHONY : run-database
66- run-database :
65+ .PHONY : run-database-es
66+ run-database-es :
6767 docker-compose run --rm elasticsearch
6868
69+ .PHONY : run-database-os
70+ run-database-os :
71+ docker-compose run --rm opensearch
72+
6973.PHONY : pybase-install
7074pybase-install :
7175 pip install wheel && \
Original file line number Diff line number Diff line change @@ -80,6 +80,10 @@ curl -X "GET" "http://localhost:8080/collections?limit=1&token=example_token"
8080``` shell
8181make test
8282```
83+
84+ ``` shell
85+ make test-opensearch
86+ ```
8387
8488## Ingest sample data
8589
Original file line number Diff line number Diff line change 77
88import attr
99from opensearchpy .helpers .search import Search
10-
1110from opensearchpy import helpers , exceptions
11+ from opensearchpy .exceptions import TransportError
12+
1213from stac_fastapi .elasticsearch import serializers
1314from stac_fastapi .elasticsearch .config .config_opensearch import AsyncSearchSettings
1415from stac_fastapi .elasticsearch .config .config_opensearch import (
@@ -187,10 +188,17 @@ async def create_collection_index() -> None:
187188
188189 index = f"{ COLLECTIONS_INDEX } -000001"
189190
190- await client .indices .create (
191- index = index ,
192- body = search_body
193- )
191+ try :
192+ await client .indices .create (
193+ index = index ,
194+ body = search_body
195+ )
196+ except TransportError as e :
197+ if e .status_code == 400 :
198+ pass # Ignore 400 status codes
199+ else :
200+ raise e
201+
194202 await client .close ()
195203
196204
@@ -213,10 +221,17 @@ async def create_item_index(collection_id: str):
213221 "settings" :ES_ITEMS_SETTINGS ,
214222 }
215223
216- await client .indices .create (
217- index = f"{ index_by_collection_id (collection_id )} -000001" ,
218- body = search_body
219- )
224+ try :
225+ await client .indices .create (
226+ index = f"{ index_name } -000001" ,
227+ body = search_body
228+ )
229+ except TransportError as e :
230+ if e .status_code == 400 :
231+ pass # Ignore 400 status codes
232+ else :
233+ raise e
234+
220235 await client .close ()
221236
222237
You can’t perform that action at this time.
0 commit comments