@@ -231,27 +231,44 @@ async def get_item(self, item_id: str, collection_id: str, **kwargs) -> Item:
231231
232232 @staticmethod
233233 def _return_date (interval_str ):
234+ """
235+ Convert a date interval string into a dictionary for filtering search results.
236+
237+ The date interval string should be formatted as either a single date or a range of dates separated
238+ by "/". The date format should be ISO-8601 (YYYY-MM-DDTHH:MM:SSZ). If the interval string is a
239+ single date, it will be converted to a dictionary with a single "eq" key whose value is the date in
240+ the ISO-8601 format. If the interval string is a range of dates, it will be converted to a
241+ dictionary with "gte" (greater than or equal to) and "lte" (less than or equal to) keys. If the
242+ interval string is a range of dates with ".." instead of "/", the start and end dates will be
243+ assigned default values to encompass the entire possible date range.
244+
245+ Args:
246+ interval_str (str): The date interval string to be converted.
247+
248+ Returns:
249+ dict: A dictionary representing the date interval for use in filtering search results.
250+ """
234251 intervals = interval_str .split ("/" )
235252 if len (intervals ) == 1 :
236- datetime = intervals [0 ][0 :19 ] + " Z"
253+ datetime = f" { intervals [0 ][0 :19 ]} Z"
237254 return {"eq" : datetime }
238255 else :
239256 start_date = intervals [0 ]
240257 end_date = intervals [1 ]
241258 if ".." not in intervals :
242- start_date = start_date [0 :19 ] + " Z"
243- end_date = end_date [0 :19 ] + " Z"
259+ start_date = f" { start_date [0 :19 ]} Z"
260+ end_date = f" { end_date [0 :19 ]} Z"
244261 elif start_date != ".." :
245- start_date = start_date [0 :19 ] + " Z"
262+ start_date = f" { start_date [0 :19 ]} Z"
246263 end_date = "2200-12-01T12:31:12Z"
247264 elif end_date != ".." :
248265 start_date = "1900-10-01T00:00:00Z"
249- end_date = end_date [0 :19 ] + " Z"
266+ end_date = f" { end_date [0 :19 ]} Z"
250267 else :
251268 start_date = "1900-10-01T00:00:00Z"
252269 end_date = "2200-12-01T12:31:12Z"
253270
254- return {"lte" : end_date , "gte" : start_date }
271+ return {"lte" : end_date , "gte" : start_date }
255272
256273 @overrides
257274 async def get_search (
@@ -269,7 +286,26 @@ async def get_search(
269286 # filter_lang: Optional[str] = None, # todo: requires fastapi > 2.3 unreleased
270287 ** kwargs ,
271288 ) -> ItemCollection :
272- """GET search catalog."""
289+ """Get search results from the database.
290+
291+ Args:
292+ collections (Optional[List[str]]): List of collection IDs to search in.
293+ ids (Optional[List[str]]): List of item IDs to search for.
294+ bbox (Optional[List[NumType]]): Bounding box to search in.
295+ datetime (Optional[Union[str, datetime_type]]): Filter items based on the datetime field.
296+ limit (Optional[int]): Maximum number of results to return.
297+ query (Optional[str]): Query string to filter the results.
298+ token (Optional[str]): Access token to use when searching the catalog.
299+ fields (Optional[List[str]]): Fields to include or exclude from the results.
300+ sortby (Optional[str]): Sorting options for the results.
301+ kwargs: Additional parameters to be passed to the API.
302+
303+ Returns:
304+ ItemCollection: Collection of `Item` objects representing the search results.
305+
306+ Raises:
307+ HTTPException: If any error occurs while searching the catalog.
308+ """
273309 base_args = {
274310 "collections" : collections ,
275311 "ids" : ids ,
0 commit comments