AggregateReturn

async def list_documents(self) → APIResponse:
“”"
Yüklenmiş tüm dökümanların doc_id ve file_name bilgilerini döndürür.
Returns:
APIResponse: Döküman listesi
“”"
try:
collection = self.client.collections.get(DOCUMENT_INDEX_NAME)
response = collection.aggregate.over_all(
group_by=GroupByAggregate(
prop=“full_doc_id”
)
)

        print(response)

        documents = []
        for group in response.groups:
            documents.append({
                "doc_id": group.grouped_by.value.split("___")[0],
                "file_name": group.grouped_by.value.split("___")[1],    
                "count": group.total_count
            })

        return documents
    except Exception as e:
        print(f"Döküman listeleme hatası: {str(e)}")
        raise e
That is my listing function for documents

I take this error :
backend-1 | content=APIResponse(is_success=False, error=str(e)).json(),
backend-1 | AggregateReturn(properties={}, total_count=None)
backend-1 | Döküman listeleme hatası: ‘AggregateReturn’ object has no attribute ‘groups’
backend-1 | INFO: 172.19.0.5:41640 - “POST /api/document/upload HTTP/1.1” 500 Internal Server Error
how can ı solve this ?

Hello @ilker_celebi,

Welcome to our community — it’s lovely to have you here! :partying_face:

‘AggregateReturn’ object has no attribute ‘groups’ :thinking:

The error sound as the result of the aggregation query doesn’t have a groups attribute as you know so the query returned no results or returned an unexpected format.

Have you tried to run it against data that 100% return a result?

Could you please confirm the versions of your Python client and Weaviate DB?

Make sure you’re using the latest Python client (v4.14.3) please try again and let me know if the issue persists.

Best regards,

Mohamed Shahin
Weaviate Support Engineer
(Ireland, GMT/UTC timezone)

2 Likes

@Mohamed_Shahin
Thank you very much for your help. Problem solved; it was related to the client version.
Best Regards.
İlker Çelebi

2 Likes