Tutorial: Build a Smart Product Catalog
Overview
Build an intelligent product catalog that understands natural language queries, provides personalized recommendations, and automatically enriches product data. By the end, you'll have a fully functional e-commerce search system that outperforms traditional keyword-based searches.
Time Required: 15 minutes Difficulty: Beginner Prerequisites: SynapCores account, Basic programming knowledge
What You'll Learn
- Creating AI-enhanced collections
- Inserting products with automatic enrichment
- Natural language product search
- Building recommendation systems
- Real-time personalization
- Performance optimization
Step 1: Create Your Product Collection
First, let's create a collection with AI capabilities enabled:
curl -X POST https://api.synapcores.com/v1/collections \
-H "Authorization: Bearer $YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "products",
"schema": {
"ai_enabled": true,
"fields": {
"sku": {"type": "string", "primary_key": true},
"name": {"type": "text", "semantic": true},
"description": {"type": "text", "semantic": true, "extract_entities": true},
"category": {"type": "string", "auto_classify": true},
"price": {"type": "float"},
"brand": {"type": "string"},
"features": {"type": "array", "items": {"type": "string"}},
"image_url": {"type": "string"},
"in_stock": {"type": "boolean"},
"rating": {"type": "float"},
"review_count": {"type": "integer"}
},
"indexes": [
{"fields": ["category", "price"], "type": "compound"},
{"fields": ["brand"], "type": "hash"},
{"fields": ["embedding"], "type": "vector", "algorithm": "hnsw"}
],
"ai_config": {
"embedding_model": "all-MiniLM-L6-v2",
"auto_generate_tags": true,
"extract_colors": true,
"sentiment_from_reviews": true
}
}
}'
Step 2: Load Sample Products
Let's add some products. SynapCores will automatically:
- Generate embeddings for semantic search
- Extract entities and features
- Classify products into categories
- Generate tags
import requests
import json
API_URL = "https://api.synapcores.com"
headers = {
"Authorization": f"Bearer {YOUR_API_TOKEN}",
"Content-Type": "application/json"
}
# Sample products
products = [
{
"sku": "LAPTOP-001",
"name": "TechPro Ultra 15",
"description": "High-performance laptop with 15.6\" 4K display, Intel i9 processor, 32GB RAM, and NVIDIA RTX 4080. Perfect for gaming, content creation, and professional work.",
"price": 1999.99,
"brand": "TechPro",
"features": ["4K Display", "32GB RAM", "1TB SSD", "RTX 4080"],
"in_stock": True,
"rating": 4.8,
"review_count": 256
},
{
"sku": "SHOES-001",
"name": "CloudRunner Pro",
"description": "Professional running shoes with advanced cushioning technology. Breathable mesh upper, responsive midsole, and durable rubber outsole.",
"price": 149.99,
"brand": "RunTech",
"features": ["Breathable Mesh", "Responsive Cushioning", "Arch Support"],
"in_stock": True,
"rating": 4.6,
"review_count": 1823
},
{
"sku": "CAMERA-001",
"name": "SnapMaster Pro X",
"description": "Professional mirrorless camera with 45MP full-frame sensor, 8K video recording, and advanced AI autofocus. Weather-sealed body.",
"price": 3499.99,
"brand": "SnapMaster",
"features": ["45MP Sensor", "8K Video", "AI Autofocus", "Weather Sealed"],
"in_stock": True,
"rating": 4.9,
"review_count": 89
}
]
# Insert products
for product in products:
response = requests.post(
f"{API_URL}/v1/collections/products/documents",
headers=headers,
json=product
)
print(f"Inserted {product['name']}: {response.status_code}")
Step 3: Natural Language Search
Now let's search using natural language instead of keywords:
Example 1: Vague Requirements
# Traditional search would fail with vague queries
query = "something for my morning jog that won't break the bank"
response = requests.post(
f"{API_URL}/v1/collections/products/search",
headers=headers,
json={
"query": query,
"limit": 5,
"explain": True
}
)
results = response.json()
for product in results["results"]:
print(f"{product['name']} - ${product['price']}")
print(f" Relevance: {product['_score']:.2f}")
print(f" Why matched: {product['_explanation']}")
# Returns: CloudRunner Pro, FitTrack Ultra
Example 2: Technical Requirements
# Complex technical search
query = "high-end device for content creation with good display"
response = requests.post(
f"{API_URL}/v1/collections/products/search",
headers=headers,
json={
"query": query,
"filters": {"in_stock": True},
"boost": {
"rating": 1.5,
"price": -0.5
}
}
)
# Returns: TechPro Ultra 15, SnapMaster Pro X
Example 3: Multi-language Support
# SynapCores understands queries in multiple languages
queries = [
"portable computer for students", # English
"ordinateur portable pour etudiants", # French
"laptop para estudiantes", # Spanish
]
for query in queries:
response = requests.post(
f"{API_URL}/v1/collections/products/search",
headers=headers,
json={"query": query, "limit": 1}
)
result = response.json()["results"][0]
print(f"{query} -> {result['name']}")
# All return: TechPro Ultra 15
Step 4: Build Recommendations
SynapCores can provide recommendations based on user behavior and product similarity:
Similar Products
# Find products similar to what the user is viewing
response = requests.post(
f"{API_URL}/v1/collections/products/similar",
headers=headers,
json={
"sku": "LAPTOP-001",
"limit": 3,
"diversity": 0.3
}
)
print("If you like TechPro Ultra 15, you might also like:")
for product in response.json()["results"]:
print(f"- {product['name']} (similarity: {product['_similarity']:.2f})")
Personalized Recommendations
# Create user preference profile based on browsing history
user_profile = {
"viewed_products": ["LAPTOP-001", "CAMERA-001"],
"purchased_categories": ["Electronics"],
"price_range": {"min": 200, "max": 2000},
"preferred_brands": ["TechPro", "SnapMaster"]
}
response = requests.post(
f"{API_URL}/v1/ai/recommend",
headers=headers,
json={
"collection": "products",
"user_profile": user_profile,
"limit": 5,
"strategy": "collaborative_content_hybrid"
}
)
print("Recommended for you:")
for rec in response.json()["recommendations"]:
print(f"- {rec['name']} (score: {rec['_score']:.2f})")
print(f" Reason: {rec['_reason']}")
Step 5: Advanced Features
Auto-Categorization
# Add a new product without specifying category
new_product = {
"sku": "TABLET-001",
"name": "SmartPad Pro",
"description": "Powerful tablet with stylus support for digital artists and note-taking",
"price": 799.99,
"brand": "SmartTech"
}
response = requests.post(
f"{API_URL}/v1/collections/products/documents",
headers=headers,
json=new_product
)
result = response.json()
print(f"Auto-categorized as: {result['category']}")
print(f"Extracted features: {result['_extracted_features']}")
print(f"Generated tags: {result['_auto_tags']}")
Faceted Search with AI
# Get intelligent facets based on current search
response = requests.post(
f"{API_URL}/v1/collections/products/facets",
headers=headers,
json={
"query": "professional equipment",
"facets": ["category", "brand", "price_range", "key_features"],
"smart_facets": True
}
)
facets = response.json()["facets"]
print("Refine your search:")
for facet_name, facet_values in facets.items():
print(f"\n{facet_name}:")
for value in facet_values[:5]:
print(f" - {value['value']} ({value['count']} items)")
Step 6: Real-time Analytics
SynapCores provides built-in analytics for your catalog:
# Analyze search trends
response = requests.get(
f"{API_URL}/v1/collections/products/analytics/search-trends",
headers=headers,
params={"period": "7d"}
)
trends = response.json()
print("Top search intents this week:")
for intent in trends["top_intents"]:
print(f"- {intent['intent']}: {intent['count']} searches")
print(f" Sample queries: {', '.join(intent['sample_queries'][:3])}")
Step 7: Performance Optimization
Query Performance
# Analyze query performance
response = requests.post(
f"{API_URL}/v1/collections/products/search",
headers=headers,
json={
"query": "laptop for gaming",
"limit": 10,
"profile": True
}
)
profile = response.json()["_profile"]
print(f"Query execution time: {profile['total_ms']}ms")
print(f"- Embedding generation: {profile['embedding_ms']}ms")
print(f"- Vector search: {profile['vector_search_ms']}ms")
print(f"- Ranking: {profile['ranking_ms']}ms")
Best Practices
1. Schema Design
# DO: Design for AI from the start
good_schema = {
"fields": {
"title": {"type": "text", "semantic": True},
"description": {"type": "text", "semantic": True, "extract_entities": True},
"specs": {"type": "json", "auto_extract_features": True}
}
}
# DON'T: Treat AI as an afterthought
bad_schema = {
"fields": {
"title": {"type": "string"}, # No semantic understanding
"desc": {"type": "text"}, # No AI features enabled
}
}
2. Query Optimization
# DO: Use filters to narrow search space
efficient_query = {
"query": "gaming laptop",
"filters": {
"category": "Computers",
"price": {"$lte": 2000}
},
"limit": 20
}
# DON'T: Retrieve everything then filter
inefficient_query = {
"query": "gaming laptop",
"limit": 1000 # Then filter in application
}
3. Caching Strategy
- Cache embedding generation (long TTL)
- Cache search results (short TTL)
- Cache user profiles (medium TTL)
Troubleshooting
-
Slow search performance
- Check index configuration
- Reduce embedding dimensions if needed
- Use filters to narrow search space
-
Irrelevant results
- Ensure semantic fields are properly configured
- Check if the right embedding model is used
- Adjust similarity thresholds
-
Categories not auto-assigned
- Verify
auto_classifyis enabled - Check if training data is sufficient
- Manually provide examples
- Verify
Summary
You've built a smart product catalog that:
- Understands natural language queries
- Provides intelligent recommendations
- Auto-enriches product data
- Scales to millions of products
- Delivers <50ms search latency
Document Version: 1.0 Last Updated: December 2025 Website: https://synapcores.com Support: support@synapcores.com