In a news retrieval system, metadata travels with each stored document to identify its source, date, and URL. Alongside vectors and source text, it supports auditability and compliance. section 11.3.4
Listing 11.8 Initializing ChromaDB and storing the embedded news
import chromadb
df = pd.read_parquet('news_embedded.parquet')
print("="*80)
print("STEP 3: VECTOR DATABASE STORAGE")
print("="*80)
# Initialize ChromaDB
chroma_client = chromadb.PersistentClient(path="./chroma_db")
# Delete old collection if exists
try:
chroma_client.delete_collection("news")
print("Deleted existing collection")
except:
pass
# Create new collection
collection = chroma_client.create_collection("news")
# Batch insert
ids = [str(i) for i in range(len(df))]
collection.add(
ids=ids,
embeddings=df['embedding'].tolist(),
documents=df['text_for_embedding'].tolist(),
metadatas=df['metadata'].tolist()
)
print(f"Stored {len(df)} documents")
print(f"Collection name: {collection.name}")
print(f"Total count: {collection.count()}")
See how ChromaDB stores metadata alongside document text and embeddings. section 11.3.4




















