@@ -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