#!/bin/bash
export LC_ALL=C
QIP=$(docker inspect qdrant --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}')
echo "qdrant: $QIP"

echo
echo "===== COLLECTION INFO ====="
curl -s --max-time 6 "http://$QIP:6333/collections/SariKnowledgeV2" | python3 -m json.tool 2>/dev/null | head -30

echo
echo "===== POINTS COUNT ====="
curl -s --max-time 6 "http://$QIP:6333/collections/SariKnowledgeV2/points/count" \
  -H 'Content-Type: application/json' -d '{"exact":true}' 2>/dev/null

echo
echo
echo "===== SEARCH LATENCY (needs a 1024-dim vector; zero vector) ====="
python3 - "$QIP" <<'PY'
import json, sys, time, urllib.request
ip = sys.argv[1]
body = json.dumps({"vector": [0.0]*1024, "limit": 3, "with_payload": False}).encode()
req = urllib.request.Request(f"http://{ip}:6333/collections/SariKnowledgeV2/points/search",
                             data=body, headers={"Content-Type": "application/json"})
t = time.time()
try:
    with urllib.request.urlopen(req, timeout=10) as r:
        d = json.load(r)
    print(f"  ok: {len(d.get('result',[]))} hits in {(time.time()-t)*1000:.0f}ms")
except Exception as e:
    print("  err:", e)
PY
