# Sample ecommerce product data
products = [
{
"product_id": "SKU001",
"title": "Premium Wireless Bluetooth Headphones",
"description": "High-quality over-ear headphones with noise cancellation and 30-hour battery life",
"category": "Electronics",
"brand": "AudioTech",
"price": 199.99,
"image_url": "https://your-cdn.com/products/headphones-001.jpg",
"tags": ["wireless", "bluetooth", "noise-cancelling", "premium"],
},
{
"product_id": "SKU002",
"title": "Organic Cotton T-Shirt",
"description": "Comfortable everyday t-shirt made from 100% organic cotton in navy blue",
"category": "Clothing",
"brand": "EcoWear",
"price": 29.99,
"image_url": "https://your-cdn.com/products/tshirt-navy-002.jpg",
"tags": ["organic", "cotton", "casual", "navy"],
},
{
"product_id": "SKU003",
"title": "Stainless Steel Water Bottle",
"description": "Insulated water bottle keeps drinks cold for 24 hours, hot for 12 hours",
"category": "Home & Kitchen",
"brand": "HydroLife",
"price": 34.99,
"image_url": "https://your-cdn.com/products/bottle-steel-003.jpg",
"tags": ["insulated", "stainless-steel", "eco-friendly", "travel"],
},
]
# Index products with multimodal mappings
response = mq.index(index_name).add_documents(
products,
client_batch_size=50, # Batch size for efficient indexing
mappings={
"product_multimodal": {
"type": "multimodal_combination",
"weights": {
"title": 0.1, # Product title importance
"image_url": 0.9, # Image visual features (highest weight)
},
}
},
tensor_fields=["product_multimodal"], # Generate embeddings for this combined field
)
print(f"Indexed {len(products)} products successfully")