check_weaviate.py 776 B

1234567891011121314151617181920212223
  1. # check_weaviate.py
  2. from src.weaviate_client import WeaviateClient
  3. import sys
  4. sys.path.insert(0, './src')
  5. client = WeaviateClient()
  6. collection = client.client.collections.get("ScientificArticle")
  7. # Loendi kokku
  8. count_response = collection.aggregate.over_all(total_count=True)
  9. total = count_response.total_count
  10. print(f"\n✅ Weaviate'is on {total} artiklit.")
  11. # Võta mõni näidis välja
  12. if total > 0:
  13. print("\n📄 Esimesed 3 artiklit:")
  14. response = collection.query.fetch_objects(limit=3)
  15. for i, obj in enumerate(response.objects):
  16. print(f"\n{i+1}. ID: {obj.properties.get('article_id', 'N/A')}")
  17. print(f" Pealkiri: {obj.properties.get('title', 'N/A')}")
  18. print(f" Autorid: {obj.properties.get('authors', ['N/A'])}")
  19. client.close()