Architecture
Understand how VortexDB works under the hood
This guide will have you inserting and searching vectors in under 60 seconds.
Make sure VortexDB is running (see Installation).
from vortexdb import VortexDB, DenseVector, Payload, Similarity
# Connect to VortexDBdb = VortexDB( grpc_url="localhost:50051", api_key="your-secure-password")
# Insert a vector with a text payloadpoint_id = db.insert( vector=DenseVector([0.1, 0.2, 0.3, 0.4]), payload=Payload.text("Hello, VortexDB!"))print(f"Inserted point: {point_id}")
# Clean updb.close()curl -X POST http://localhost:3000/points \ -H "Content-Type: application/json" \ -d '{ "vector": [0.1, 0.2, 0.3, 0.4], "payload": { "content_type": "Text", "content": "Hello, VortexDB!" } }'Response:
{ "point_id": "550e8400-e29b-41d4-a716-446655440000"}// Using grpcurlgrpcurl -plaintext \ -H "authorization: your-secure-password" \ -d '{ "vector": {"values": [0.1, 0.2, 0.3, 0.4]}, "payload": {"content_type": 1, "content": "Hello, VortexDB!"} }' \ localhost:50051 vectordb.VectorDB/InsertVectorfrom vortexdb import VortexDB, DenseVector, Similarity
db = VortexDB( grpc_url="localhost:50051", api_key="your-secure-password")
# Search for 5 most similar vectors using cosine similarityresults = db.search( vector=DenseVector([0.1, 0.2, 0.3, 0.4]), similarity=Similarity.COSINE, limit=5)
print(f"Found {len(results)} similar vectors:")for point_id in results: print(f" - {point_id}")
db.close()curl -X POST http://localhost:3000/points/search \ -H "Content-Type: application/json" \ -d '{ "vector": [0.1, 0.2, 0.3, 0.4], "similarity": "Cosine", "limit": 5 }'Response:
{ "results": [ "550e8400-e29b-41d4-a716-446655440000", "6ba7b810-9dad-11d1-80b4-00c04fd430c8" ]}# Get the point you just insertedpoint = db.get(point_id=point_id)
if point: print(point.pretty()) # Output: # Point ID: 550e8400-e29b-41d4-a716-446655440000 # Vector: [0.1, 0.2, 0.3, 0.4] # Payload: Hello, VortexDB!curl http://localhost:3000/points/550e8400-e29b-41d4-a716-446655440000Response:
{ "id": "550e8400-e29b-41d4-a716-446655440000", "vector": [0.1, 0.2, 0.3, 0.4], "payload": { "content_type": "Text", "content": "Hello, VortexDB!" }}db.delete(point_id=point_id)print("Point deleted successfully")curl -X DELETE http://localhost:3000/points/550e8400-e29b-41d4-a716-446655440000Here’s a complete example using the Python SDK with context manager:
from vortexdb import VortexDB, DenseVector, Payload, Similarity
# Using context manager for automatic cleanupwith VortexDB(grpc_url="localhost:50051", api_key="secret") as db: # Insert some vectors vectors = [ ([0.1, 0.2, 0.3, 0.4], "First document"), ([0.2, 0.3, 0.4, 0.5], "Second document"), ([0.9, 0.8, 0.7, 0.6], "Third document"), ]
point_ids = [] for vec, text in vectors: pid = db.insert( vector=DenseVector(vec), payload=Payload.text(text) ) point_ids.append(pid) print(f"Inserted: {text} -> {pid}")
# Search for vectors similar to the first one results = db.search( vector=DenseVector([0.15, 0.25, 0.35, 0.45]), similarity=Similarity.COSINE, limit=2 )
print(f"\nTop 2 similar vectors:") for pid in results: point = db.get(point_id=pid) print(f" - {point.payload.content}")