Skip to content

Commit 7542398

Browse files
committed
Add error message to post search
1 parent 1262e89 commit 7542398

File tree

1 file changed

+5
-1
lines changed
  • stac_fastapi/elasticsearch/stac_fastapi/elasticsearch

1 file changed

+5
-1
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,11 @@ def post_search(
320320
field = sort.field + ".keyword"
321321
search = search.sort({field: {"order": sort.direction}})
322322

323-
count = search.count()
323+
try:
324+
count = search.count()
325+
except elasticsearch.exceptions.NotFoundError:
326+
raise NotFoundError("No items have been added to the database yet")
327+
324328
# search = search.sort({"id.keyword" : {"order" : "asc"}})
325329
search = search.query()[0 : search_request.limit]
326330
response = search.execute().to_dict()

0 commit comments

Comments
 (0)