Skip to main content

Hybrid Search

Search bars are often the first place users turn to find what they need, whether it's a specific product on an e-commerce site, an article on a news site, or a video on a streaming service. A good search experience feels effortless, quickly connecting users with relevant results. However, traditional keyword search often falls short. It treats every user the same, relying solely on matching terms in a query to terms in item descriptions. This "one-size-fits-all" approach ignores valuable context about the individual user's preferences, past behavior, and overall intent, frequently leading to generic, irrelevant, or overwhelming results.

Imagine two users searching for "python" on a technical learning platform. One is a data science beginner interested in introductory courses, while the other is an experienced web developer looking for advanced Django frameworks. Standard keyword search might show them the exact same results, forcing both to sift through irrelevant content. Personalized search, on the other hand, understands the individual behind the query. It leverages user history and preferences alongside the search terms to deliver results tailored specifically to each person, dramatically improving relevance, engagement, and task completion. Building this sophisticated capability from scratch, however, is a significant engineering undertaking.

Implementing Search with Shaped

Let's illustrate how to use Shaped for both standard keyword and personalized search.

Goal: Implement search functionality, offering both basic keyword matching and a personalized experience.

1. Ensure Data is Connected: Assume user_interactions and item_metadata (with searchable text fields like title, description) are connected to Shaped.

2. Define Your Shaped Model (YAML): A standard model definition works. Ensure text fields intended for search are included as item features. The same model can power recommendations and personalized search.

search_personalization_model.yaml

model:
name: discovery_model # Can be used for recs and search
connectors:
- type: Dataset
name: user_interactions
id: interactions
- type: Dataset
name: item_metadata # Ensure relevant text fields are included
id: items
fetch:
events: |
SELECT user_id, item_id, timestamp AS created_at, event_type FROM interactions
items: |
SELECT
item_id,
title, # Searchable field
description, # Searchable field
category,
image_url,
product_url
FROM items

3. Create the Model:

shaped create-model --file search_personalization_model.yaml  

4. Monitor Training: Wait for the model discovery_model to become ACTIVE.

shaped view-model --model-name discovery_model  

5. Fetch Search Results (Application Backend Logic):

  • Option A: Standard Keyword Search (using retrieve) Use this for non-personalized keyword matching.
const { Shaped } = require('@shaped/shaped');

const shapedClient = new Shaped();
const response = await shapedClient.retrieve({
modelName: "discovery_model",
textQuery: "machine learning basics",
limit: limit,
returnMetadata: true
});
  • Option B: Personalized Search (using rank + text_query) Use this to get results ranked by both keyword relevance and user preference.
const { Shaped } = require('@shaped/shaped');

const shapedClient = new Shaped();
const response = await shapedClient.rank({
modelName: "discovery_model",
textQuery: "machine learning basics",
user_id: "USER_123", // Add user ID for personalization.
limit: limit,
returnMetadata: true
});

Conclusion: Deliver Search That Truly Understands Users

Standard keyword search often leaves users frustrated, forcing them to sift through irrelevant results. Building a truly personalized search experience traditionally requires integrating and managing complex search indexing, machine learning, and real-time serving systems.

Shaped offers a radically simpler, unified approach. By combining high-performance keyword retrieval (retrieve) with powerful, AI-driven personalized ranking (rank with text_query), Shaped allows you to deliver search results that are not only relevant to the query but also deeply tailored to each individual user's preferences and history. Leverage the same models and data that power your recommendations to create a seamless, intelligent discovery experience across your entire platform, boosting engagement and user satisfaction.

Ready to transform your search from a simple lookup tool into a personalized discovery engine?

Request a demo of Shaped today to see it in action with your specific use case. Or, start exploring immediately with our free trial sandbox.