Skip to content

Commit d3e6591

Browse files
committed
fix all_collections missing index
1 parent 4eaedc5 commit d3e6591

File tree

1 file changed

+6
-3
lines changed
  • stac_fastapi/elasticsearch/stac_fastapi/elasticsearch

1 file changed

+6
-3
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ def _lookup_id(id: str, table, session):
5252
def all_collections(self, **kwargs) -> Collections:
5353
"""Read all collections from the database."""
5454
base_url = str(kwargs["request"].base_url)
55-
collections = self.client.search(
56-
index="stac_collections", doc_type="_doc", query={"match_all": {}}
57-
)
55+
try:
56+
collections = self.client.search(
57+
index="stac_collections", doc_type="_doc", query={"match_all": {}}
58+
)
59+
except elasticsearch.exceptions.NotFoundError:
60+
raise NotFoundError(f"No collections exist in the database yet")
5861
serialized_collections = [
5962
self.collection_serializer.db_to_stac(
6063
collection["_source"], base_url=base_url

0 commit comments

Comments
 (0)