100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Vector Databases (Pinecone/Weaviate) Cheat Sheet

Vector Databases (Pinecone/Weaviate) Cheat Sheet

Explains vector database fundamentals such as embeddings, ANN search, and metadata filtering, with practical Pinecone and Weaviate setup examples.

2 PagesIntermediateMar 15, 2026

Pinecone Setup & Query

Create a serverless index, upsert vectors, and run a filtered similarity search.

python
from pinecone import Pinecone, ServerlessSpecpc = Pinecone(api_key="YOUR_API_KEY")# Create a serverless index (dimension must match your embedding model)pc.create_index(    name="products",    dimension=1536,    metric="cosine",          # cosine | euclidean | dotproduct    spec=ServerlessSpec(cloud="aws", region="us-east-1"))index = pc.Index("products")# Upsert vectors with metadataindex.upsert(vectors=[    {"id": "vec1", "values": [0.1, 0.2, 0.3], "metadata": {"category": "shoes"}},    {"id": "vec2", "values": [0.4, 0.1, 0.9], "metadata": {"category": "bags"}},])# Query for nearest neighbors, filtered by metadataresults = index.query(    vector=[0.1, 0.2, 0.3],    top_k=5,    include_metadata=True,    filter={"category": {"$eq": "shoes"}})

Weaviate Setup & Query

Connect to Weaviate Cloud, define a collection with an auto-vectorizer, and run semantic search.

python
import weaviatefrom weaviate.classes.init import Authfrom weaviate.classes.config import Configure, Property, DataTypeclient = weaviate.connect_to_weaviate_cloud(    cluster_url="https://your-cluster.weaviate.network",    auth_credentials=Auth.api_key("YOUR_API_KEY"),)# Create a collection with a built-in vectorizer modulearticles = client.collections.create(    name="Article",    vectorizer_config=Configure.Vectorizer.text2vec_openai(),    properties=[        Property(name="title", data_type=DataType.TEXT),        Property(name="body", data_type=DataType.TEXT),    ],)# Insert an object (Weaviate auto-generates the embedding)articles.data.insert({"title": "Hello", "body": "World"})# Semantic searchresponse = articles.query.near_text(query="machine learning", limit=5)for obj in response.objects:    print(obj.properties)client.close()

Core Concepts

Vocabulary shared across most vector database products.

  • Embedding- A dense numeric vector (commonly 384-1536 dims) produced by an ML model that captures the semantic meaning of text, images, or audio.
  • HNSW- Hierarchical Navigable Small World, the graph-based approximate nearest neighbor (ANN) algorithm both Pinecone and Weaviate use by default for fast similarity search.
  • Cosine similarity- The default distance metric for most text embeddings; measures the angle between two vectors while ignoring magnitude.
  • Namespace (Pinecone)- A logical partition within a Pinecone index used to isolate tenants or data subsets without creating separate indexes.
  • Collection (Weaviate)- Weaviate's equivalent of a table/schema; defines properties, vectorizer, and index configuration for a set of objects.
  • Hybrid search- Combines dense vector similarity with sparse keyword (BM25) search; supported natively by both Pinecone (via sparse-dense vectors) and Weaviate's hybrid() query.
  • Metadata filtering- Restricts ANN search to vectors matching structured filters (category, date, tenant) applied alongside the vector search.
  • top_k / limit- The number of nearest neighbors to return; larger values trade off latency and recall.

Pinecone vs. Weaviate

Key differences to consider when choosing between the two.

  • Deployment- Pinecone: fully managed, serverless-only SaaS. Weaviate: open-source (self-host via Docker/Kubernetes) or Weaviate Cloud managed offering.
  • Vectorization- Pinecone stores and searches vectors you supply (bring your own embeddings, or use its integrated inference API). Weaviate can auto-vectorize objects at insert time via built-in modules.
  • Query interface- Pinecone uses a simple query() call with a filter dict. Weaviate uses GraphQL under the hood plus a fluent Python/TS client (near_text, near_vector, bm25, hybrid).
  • Multi-tenancy- Pinecone isolates tenants with namespaces per index. Weaviate has explicit multi-tenancy support per collection with isolated tenant shards.
  • Data model- Pinecone stores id + vector + flat metadata. Weaviate collections have typed schemas (properties), closer to a document database.
  • Scaling- Pinecone serverless auto-scales storage/compute per index. Weaviate scaling depends on the cluster/shard configuration you provision when self-hosted.
Pro Tip

When you switch embedding models, re-embed and re-upsert every vector — cosine distance between vectors produced by different models is meaningless, and silently mixing them corrupts search quality without throwing any error.

Was this cheat sheet helpful?

Explore Topics

#VectorDatabasesPineconeWeaviate#VectorDatabasesPineconeWeaviateCheatSheet#Database#Intermediate#PineconeSetupQuery#WeaviateSetupQuery#CoreConcepts#PineconeVsWeaviate#Databases#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet