Prompt
How do I rank search results and recommendations together?
Latest observation
To rank search results and recommendations together, treat them as candidate items from different sources and score them in a shared ranking layer.
Common approach
1) Generate candidates from both sources
- Search: items matching the user query
- Recommendations: items from collaborative filtering, content-based models, trending, etc.
2) Normalize into one candidate set
Give each item a common representation:
item_idsource=searchorrecommendation- features:
- query relevance
- user-item affinity
- popularity
- freshness
- personalization signals
- diversity / business rules
3) Use one scoring model
Train or define a model that predicts a unified objective such as:
- click-through rate
- conversion probability
- engagement value
- utility / expected value
Example: [ score = w_1 \cdot relevance + w_2 \cdot personalization + w_3 \cdot freshness + w_4 \cdot popularity + w_5 \cdot business_rules ]
4) Calibrate scores across sources
Search and recommendation scores often live on different scales, so normalize them before merging:
- min-max scaling
- z-score normalization
- Platt scaling / isotonic calibration
- per-source score calibration
Without this, one source can dominate unfairly.
5) Add source-aware features
Let the ranker know where the item came from:
is_search_candidateis_recommended_candidate- query intent strength
- explicit vs implicit intent
This helps the model learn when search should dominate versus when recommendations should.
6) Apply re-ranking for mix quality
After initial scoring, adjust the final list for:
- diversity
- novelty
- deduplication
- source balance
- business constraints
For example:
- if query intent is strong, show mostly search results first
- if query is vague or empty, show more recommendations
Practical ranking strategies
A. Single blended ranker
Best when you want one unified list.
- Combine all candidates
- Train one model
- Rank by predicted utility
Pros: simplest user experience
Cons: needs good calibration and training data
B. Two-stage with source blending
- Rank search results separately
- Rank recommendations separately
- Merge with a blending rule
Example:
- top 5 search results
- top 3 recommendations
- interleave if scores are close
Pros: easy to control
Cons: less optimal than a true unified ranker
C. Intent-aware mixing
Use query context to decide the mix:
- strong navigational query → mostly search
- exploratory query → mix search and recommendations
- no query / home feed → mostly recommendations
This often works very well in production.
Important data requirement
To train a unified ranker, you need logs of:
- what candidates were shown
- their source
- their positions
- clicks, conversions, dwell time, etc.
Be careful about position bias and source bias in training data.
A simple production recipe
If you want something practical:
- Retrieve top N from search
- Retrieve top M from recommendation systems
- Normalize scores per source
- Train a learning-to-rank model on combined features
- Re-rank with diversity and business rules
- Monitor CTR, conversion, and source mix
If you want a very simple formula
You can combine them like this:
[ final_score = \alpha \cdot normalized_search_score + (1-\alpha) \cdot normalized_rec_score ]
Where (\alpha) depends on intent:
- high query intent → larger (\alpha)
- low query intent → smaller (\alpha)
If you want, I can also give you:
- a concrete ranking architecture,
- a machine learning feature set, or
- pseudocode for merging search and recommendation results.