File size: 2,252 Bytes
29fd274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import sys
from pathlib import Path

backend_dir = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(backend_dir))

from dotenv import load_dotenv
load_dotenv(backend_dir / ".env")

from app.config import get_settings
from qdrant_client import QdrantClient

def main():
    settings = get_settings()
    url = settings.qdrant_url
    key = settings.qdrant_api_key
    collection = settings.qdrant_collection

    print("=" * 65)
    print("MatchLens Qdrant Cloud Inspection Tool")
    print("=" * 65)
    print(f"Target URL:        {url}")
    print(f"Collection Name:   {collection}")

    if not url or not key:
        print("ERROR: QDRANT_URL or QDRANT_API_KEY is not set in backend/.env")
        return

    client = QdrantClient(url=url, api_key=key, timeout=15)
    
    # 1. Cluster collections
    colls = client.get_collections()
    collection_names = [c.name for c in colls.collections]
    print(f"Available Collections in Cluster: {collection_names}")
    
    if collection not in collection_names:
        print(f"WARNING: Collection '{collection}' does not exist on cluster!")
        return

    # 2. Collection statistics
    info = client.get_collection(collection)
    print("-" * 65)
    print(f"Collection Status: {info.status}")
    print(f"Total Points:      {info.points_count}")
    print(f"Vector Dimensions: {info.config.params.vectors.size}")
    print(f"Distance Metric:   {info.config.params.vectors.distance}")
    print("-" * 65)

    # 3. Scroll and display all ingested document payloads
    points, _ = client.scroll(
        collection_name=collection,
        limit=20,
        with_payload=True,
        with_vectors=False,
    )

    print(f"Stored Documents & Embeddings ({len(points)} points retrieved):\n")
    for idx, pt in enumerate(points, 1):
        payload = pt.payload or {}
        print(f"[{idx}] Point ID: {pt.id}")
        print(f"    Title:   {payload.get('title')}")
        print(f"    Source:  {payload.get('source_url')}")
        content = payload.get('content', '')
        print(f"    Preview: {content[:130].strip()}...")
        print()

    print("=" * 65)
    print("All points are verified and indexed in Qdrant Cloud.")

if __name__ == "__main__":
    main()