Skip to content

Commit c8123be

Browse files
committed
Adding missing async-ness.
1 parent e7943ba commit c8123be

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ async def post_search(
607607
if hasattr(search_request, "filter_expr"):
608608
cql2_filter = getattr(search_request, "filter_expr", None)
609609
try:
610-
search = self.database.apply_cql2_filter(search, cql2_filter)
610+
search = await self.database.apply_cql2_filter(search, cql2_filter)
611611
except Exception as e:
612612
raise HTTPException(
613613
status_code=400, detail=f"Error with cql2_json filter: {e}"

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,13 @@ async def get_queryables_mapping(self, collection_id: str = "*") -> dict:
307307
)
308308

309309
for mapping in mappings.values():
310-
fields = mapping["mappings"]["properties"]
311-
properties = fields.pop("properties")
310+
fields = mapping["mappings"].get("properties", {})
311+
properties = fields.pop("properties", {}).get("properties", {}).keys()
312312

313313
for field_key in fields:
314314
queryables_mapping[field_key] = field_key
315315

316-
for property_key in properties["properties"]:
316+
for property_key in properties:
317317
queryables_mapping[property_key] = f"properties.{property_key}"
318318

319319
return queryables_mapping
@@ -546,7 +546,9 @@ def apply_free_text_filter(search: Search, free_text_queries: Optional[List[str]
546546

547547
return search
548548

549-
def apply_cql2_filter(self, search: Search, _filter: Optional[Dict[str, Any]]):
549+
async def apply_cql2_filter(
550+
self, search: Search, _filter: Optional[Dict[str, Any]]
551+
):
550552
"""
551553
Apply a CQL2 filter to an Elasticsearch Search object.
552554
@@ -566,7 +568,7 @@ def apply_cql2_filter(self, search: Search, _filter: Optional[Dict[str, Any]]):
566568
otherwise the original Search object.
567569
"""
568570
if _filter is not None:
569-
es_query = filter.to_es(self.get_queryables_mapping(), _filter)
571+
es_query = filter.to_es(await self.get_queryables_mapping(), _filter)
570572
search = search.query(es_query)
571573

572574
return search

0 commit comments

Comments
 (0)