Careeroza
Real World Example
Semantic Product Search
Flipkart, Myntra and Meesho let shoppers search in their own words ("shaadi ke liye red lehenga under 5000"). Behind it: product text is embedded, stored with price/stock/category payloads, and searched with filters. A ShopEase version with Qdrant:
from qdrant_client import QdrantClient, models
import voyageai
vo = voyageai.Client()
qdrant = QdrantClient(url="http://localhost:6333")
qdrant.create_collection(
collection_name="products",
vectors_config=models.VectorParams(size=1024, distance=models.Distance.COSINE),
)
products = load_products() # [{"id": 1, "title": ..., "description": ..., "price": ..., "in_stock": ...}]
vectors = vo.embed([p["title"] + ". " + p["description"] for p in products],
model="voyage-3.5", input_type="document").embeddings
qdrant.upsert(collection_name="products", points=[
models.PointStruct(id=p["id"], vector=v, payload={"title": p["title"], "price": p["price"], "in_stock": p["in_stock"]})
for p, v in zip(products, vectors)
])
def search(query: str, max_price: int):
qv = vo.embed([query], model="voyage-3.5", input_type="query").embeddings[0]
hits = qdrant.query_points(
collection_name="products", query=qv, limit=3,
query_filter=models.Filter(must=[
models.FieldCondition(key="price", range=models.Range(lte=max_price)),
models.FieldCondition(key="in_stock", match=models.MatchValue(value=True)),
]),
).points
return [(round(h.score, 3), h.payload["title"], h.payload["price"]) for h in hits]
print(search("red lehenga for a wedding", max_price=5000))Run it
python product_search.pyExample output
[(0.812, 'Maroon silk lehenga choli with dupatta', 4599), (0.794, 'Red bridal georgette lehenga, embroidered', 4999), (0.731, 'Rani pink festive lehenga set', 3899)]
In Practice
- The price limit comes from parsing the query ("under 5000"), often with a small LLM call using structured output.
- Shops mix semantic scores with keyword search, popularity and personalization (hybrid search is covered in the advance level).
- Re-embed a product when its title or description changes.