By Sagar Shankaran, Founder of CallSphere
Learn to set up Weaviate, design schemas with vectorizer modules, import data, and run hybrid keyword-plus-vector searches using Weaviate's GraphQL API and Python client.
Key takeaways
Weaviate is an open-source vector database with two distinctive features: a GraphQL API for flexible querying and a modular architecture that plugs in embedding models, rerankers, and generative AI directly at the database level. Instead of embedding documents in your application code and sending vectors to the database, Weaviate can handle vectorization internally using modules like text2vec-openai or text2vec-cohere.
This module-based approach simplifies your application code. You send raw text to Weaviate, and it generates, stores, and indexes the embeddings automatically. Combined with hybrid search (keyword BM25 + vector similarity), Weaviate is a strong choice for applications that need both traditional and semantic search.
The fastest way to run Weaviate locally is with Docker Compose. Create a docker-compose.yml:
flowchart TD
DOC(["Document"])
CHUNK["Chunker<br/>recursive plus overlap"]
EMB["Embedding model"]
META["Attach metadata<br/>source, page, tenant"]
INDEX[("HNSW or IVF index<br/>in vector store")]
Q(["Query"])
QEMB["Embed query"]
SEARCH["ANN search<br/>cosine similarity"]
FILTER["Metadata filter<br/>tenant or date"]
HITS(["Top-k chunks"])
DOC --> CHUNK --> EMB --> META --> INDEX
Q --> QEMB --> SEARCH
INDEX --> SEARCH --> FILTER --> HITS
style INDEX fill:#4f46e5,stroke:#4338ca,color:#fff
style HITS fill:#059669,stroke:#047857,color:#fff
version: '3.4'
services:
weaviate:
image: cr.weaviate.io/semitechnologies/weaviate:1.28.0
ports:
- "8080:8080"
- "50051:50051"
environment:
QUERY_DEFAULTS_LIMIT: 25
AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: "true"
DEFAULT_VECTORIZER_MODULE: "text2vec-openai"
ENABLE_MODULES: "text2vec-openai,generative-openai"
OPENAI_APIKEY: "sk-your-key-here"
CLUSTER_HOSTNAME: "node1"
Start the server:
docker compose up -d
Install the Python client:
Hear it before you finish reading
Talk to a live CallSphere AI voice agent in your browser — 60 seconds, no signup.
pip install weaviate-client
import weaviate
from weaviate.classes.init import Auth
# Local instance
client = weaviate.connect_to_local()
# Weaviate Cloud
client = weaviate.connect_to_weaviate_cloud(
cluster_url="https://your-cluster.weaviate.network",
auth_credentials=Auth.api_key("your-weaviate-api-key"),
headers={"X-OpenAI-Api-Key": "sk-..."}
)
print(client.is_ready())
In Weaviate, a collection (formerly called a "class") defines the structure of your data. Each collection has properties and a vectorizer configuration:
from weaviate.classes.config import Configure, Property, DataType
client.collections.create(
name="Article",
vectorizer_config=Configure.Vectorizer.text2vec_openai(
model="text-embedding-3-small"
),
properties=[
Property(name="title", data_type=DataType.TEXT),
Property(name="content", data_type=DataType.TEXT),
Property(name="category", data_type=DataType.TEXT),
Property(name="word_count", data_type=DataType.INT),
]
)
Weaviate will automatically vectorize the TEXT properties when you insert data. You can skip vectorization for specific properties by setting skip_vectorization=True.
Insert objects and Weaviate generates embeddings automatically:
articles = client.collections.get("Article")
articles.data.insert({
"title": "Introduction to Vector Databases",
"content": "Vector databases store and search high-dimensional embeddings...",
"category": "databases",
"word_count": 450
})
# Batch import for large datasets
with articles.batch.dynamic() as batch:
for doc in documents:
batch.add_object(properties={
"title": doc["title"],
"content": doc["content"],
"category": doc["category"],
"word_count": doc["word_count"]
})
Search by semantic meaning without computing embeddings yourself:
from weaviate.classes.query import MetadataQuery
articles = client.collections.get("Article")
response = articles.query.near_text(
query="how vector similarity search works",
limit=5,
return_metadata=MetadataQuery(distance=True)
)
for obj in response.objects:
print(f"{obj.properties['title']} (distance: {obj.metadata.distance:.4f})")
Combine BM25 keyword search with vector similarity for the best of both worlds:
Still reading? Stop comparing — try CallSphere live.
CallSphere ships complete AI voice agents per industry — 14 tools for healthcare, 10 agents for real estate, 4 specialists for salons. See how it actually handles a call before you book a demo.
response = articles.query.hybrid(
query="PostgreSQL vector extension performance",
limit=5,
alpha=0.5, # 0 = pure keyword, 1 = pure vector
return_metadata=MetadataQuery(score=True)
)
for obj in response.objects:
print(f"{obj.properties['title']} (score: {obj.metadata.score:.4f})")
The alpha parameter controls the balance. Start at 0.5 and adjust based on your use case — content with specialized terminology often benefits from a lower alpha that weights keyword matching more heavily.
Apply filters alongside vector or hybrid search:
from weaviate.classes.query import Filter
response = articles.query.near_text(
query="database performance",
limit=10,
filters=Filter.by_property("category").equal("databases") &
Filter.by_property("word_count").greater_than(200)
)
No. Weaviate's vectorizer modules handle embedding generation at the database level. You send raw text, and the configured module (like text2vec-openai) generates and stores the embedding. You only need to manage embeddings yourself if you use the none vectorizer and provide your own vectors.
nearText sends your query string to the vectorizer module, which generates an embedding and then searches. nearVector accepts a pre-computed vector directly. Use nearText for simplicity; use nearVector when you embed queries externally or want to reuse embeddings across multiple searches.
Yes. Use the text2vec-transformers module instead of text2vec-openai. This runs a transformer model locally inside a Docker container alongside Weaviate. It is slower and uses more memory but requires no external API calls or keys.
#Weaviate #VectorDatabase #GraphQL #HybridSearch #Python #AgenticAI #LearnAI #AIEngineering

Written by
Sagar Shankaran· Founder, CallSphere
LinkedInSagar Shankaran is the founder of CallSphere, where he builds production AI voice and chat agents deployed across healthcare, hospitality, real estate, and home services. He writes about agentic AI, LLM engineering, and shipping voice agents that handle real calls in production.
See how AI voice agents work for your industry. Live demo available -- no signup required.
Step-by-step build of a working agent with the OpenAI Agents SDK — Agent class, tools, handoffs, tracing — plus an eval pipeline that catches regressions before merge.
Smolagents lets agents write Python instead of JSON. Why code-as-action reduces tool errors and where the security trade-offs are for production deployments.
The four major vector index algorithms in 2026 — HNSW, IVF, ScaNN, DiskANN — and which one fits your scale, recall, and latency budget.
Pure dense retrieval is not enough. The 2026 hybrid search stack that combines BM25, dense, ColBERT-V2, and learned sparse vectors.
RRF is a one-line fusion trick that beats most learned re-rankers on real RAG workloads. Why it works and when ML re-rankers are still worth it.
Per-vector cost economics matter at scale. The 2026 numbers for storage, compute, egress, and how to model TCO.
© 2026 CallSphere Inc. All rights reserved.
Made within San Francisco
Watch how CallSphere handles real customer calls, schedules appointments, and processes payments — live.
Try Live DemoBook a DemoCalculate Your ROI