|
21 | 21 | from stac_fastapi.elasticsearch.models.links import PagingLinks |
22 | 22 | from stac_fastapi.elasticsearch.serializers import CollectionSerializer, ItemSerializer |
23 | 23 | from stac_fastapi.elasticsearch.session import Session |
24 | | -from stac_fastapi.extensions.core.filter.request import FilterLang |
25 | 24 | from stac_fastapi.extensions.third_party.bulk_transactions import ( |
26 | 25 | BaseBulkTransactionsClient, |
27 | 26 | Items, |
@@ -108,9 +107,8 @@ async def item_collection( |
108 | 107 | collection = await self.get_collection( |
109 | 108 | collection_id=collection_id, request=request |
110 | 109 | ) |
111 | | - try: |
112 | | - collection_id = collection["id"] |
113 | | - except Exception: |
| 110 | + collection_id = collection.get("id") |
| 111 | + if collection_id is None: |
114 | 112 | raise HTTPException(status_code=404, detail="Collection not found") |
115 | 113 |
|
116 | 114 | search = self.database.make_search() |
@@ -311,14 +309,15 @@ async def post_search( |
311 | 309 | search=search, op=op, field=field, value=value |
312 | 310 | ) |
313 | 311 |
|
314 | | - filter_lang = getattr(search_request, "filter_lang", None) |
315 | | - |
| 312 | + # only cql2_json is supported here |
316 | 313 | if hasattr(search_request, "filter"): |
317 | 314 | cql2_filter = getattr(search_request, "filter", None) |
318 | | - if filter_lang in [None, FilterLang.cql2_json, FilterLang.cql_json]: |
| 315 | + try: |
319 | 316 | 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 | + ) |
322 | 321 |
|
323 | 322 | sort = None |
324 | 323 | if search_request.sortby: |
|
0 commit comments