Skip to content

Commit 0c6e508

Browse files
authored
Merge branch 'main' into implement-fields-extension
2 parents d024cf6 + 80c246f commit 0c6e508

File tree

1 file changed

+8
-9
lines changed
  • stac_fastapi/elasticsearch/stac_fastapi/elasticsearch

1 file changed

+8
-9
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from stac_fastapi.elasticsearch.models.links import PagingLinks
2222
from stac_fastapi.elasticsearch.serializers import CollectionSerializer, ItemSerializer
2323
from stac_fastapi.elasticsearch.session import Session
24-
from stac_fastapi.extensions.core.filter.request import FilterLang
2524
from stac_fastapi.extensions.third_party.bulk_transactions import (
2625
BaseBulkTransactionsClient,
2726
Items,
@@ -108,9 +107,8 @@ async def item_collection(
108107
collection = await self.get_collection(
109108
collection_id=collection_id, request=request
110109
)
111-
try:
112-
collection_id = collection["id"]
113-
except Exception:
110+
collection_id = collection.get("id")
111+
if collection_id is None:
114112
raise HTTPException(status_code=404, detail="Collection not found")
115113

116114
search = self.database.make_search()
@@ -311,14 +309,15 @@ async def post_search(
311309
search=search, op=op, field=field, value=value
312310
)
313311

314-
filter_lang = getattr(search_request, "filter_lang", None)
315-
312+
# only cql2_json is supported here
316313
if hasattr(search_request, "filter"):
317314
cql2_filter = getattr(search_request, "filter", None)
318-
if filter_lang in [None, FilterLang.cql2_json, FilterLang.cql_json]:
315+
try:
319316
search = self.database.apply_cql2_filter(search, cql2_filter)
320-
else:
321-
raise Exception("CQL2-Text is not supported with POST")
317+
except Exception as e:
318+
raise HTTPException(
319+
status_code=400, detail=f"Error with cql2_json filter: {e}"
320+
)
322321

323322
sort = None
324323
if search_request.sortby:

0 commit comments

Comments
 (0)