diff --git a/gdrive/export_api.py b/gdrive/export_api.py index 0f7b88d..6c9ddd3 100644 --- a/gdrive/export_api.py +++ b/gdrive/export_api.py @@ -138,7 +138,7 @@ class FindModel(BaseModel): Request body format for the `/find` endpoint """ - responseId: str + responseId: str | list[str] field: str values: list[str] = Field(..., min_items=1) result_field: str | None = None @@ -148,5 +148,8 @@ class FindModel(BaseModel): async def find(find: FindModel): # for given responseid, find all occurences of result = find.result_field if find.result_field is not None else find.field - export_data = export_client.find(find.responseId, find.field, find.values, result) + responseId = ( + find.responseId if isinstance(find.responseId, list) else [find.responseId] + ) + export_data = export_client.find(responseId, find.field, find.values, result) return export_data diff --git a/gdrive/export_client.py b/gdrive/export_client.py index 6e1ef36..79fbaec 100644 --- a/gdrive/export_client.py +++ b/gdrive/export_client.py @@ -272,7 +272,9 @@ def find(responseId, field, values, result): hosts=[{"host": settings.ES_HOST, "port": settings.ES_PORT}], timeout=300 ) - all_interactionIds = get_all_InteractionIds(responseId) + all_interactionIds = [] + for resid in responseId: + all_interactionIds.extend(get_all_InteractionIds(resid)) if len(all_interactionIds) == 0: return {"found": []} @@ -306,7 +308,7 @@ def find(responseId, field, values, result): ] } }, - "_source": [result], + "_source": ["interactionId", result], } found_result = es.search(body=json.dumps(query_found), index="_all")