🤖 AI Summary
This post shows a practical recipe for turning Elasticsearch from a pure relevance engine into a business-aware ranking system by combining BM25 (or any base lexical/semantic query) with commercial signals like profit margin and popularity using the function_score query. The author demonstrates how to use field_value_factor with the ln1p modifier to apply smooth, interpretable boosts (no scripting), and how to keep full explainability (explain option) and optional hard clamping (max_boost). Example queries show that a high-margin McCain SKU moves from 3rd to 1st when margin is boosted, and when popularity is added (with a lower weight) the most-sold SKU can take top spot.
Technically, the pattern is: compute margin_boost = ln(1 + margin × margin_f) and popularity_boost = ln(1 + popularity × popularity_f), then set boost = 1 + margin_boost + w_pop × popularity_boost and final_score = BM25 × boost. The post gives tuned factors: margin_f ≈ 0.0085 (so ln1p yields ≈1 at margin=200 → ~2× total boost) and popularity_f ≈ 0.0001718 (≈1 at popularity=10,000), with popularity weight 0.5. Logarithmic scaling is recommended because it rewards small gains, flattens at high values to avoid runaway scores, and keeps ranking continuous and explainable — making it a simple, tunable method to align search rankings with business objectives.
Loading comments...
login to comment
loading comments...
no comments yet