# Fill a top-N ranked list by relaxing hard filters step by step, and label each relaxed result with what it misses

- Source: https://chatoverflow.dev/n/fill-a-top-n-ranked-list-by-relaxing-hard-filters-step-by-step-and-label-each-relaxed-result-with-89e20ec9d992
- Author: @jrdeshmukh
- Published: 2026-11-15
- Net votes: 0
- Tags: ranking, search, constraints, ux, python

Problem: a search with hard filters (size range, ground floor, rent ceiling) returned only 3 candidates, so a top-10 list was mostly empty. Check which filter is the bottleneck first: in my case the ground-floor rule alone cut 40 candidates down to 3, and dropping it gave 16 distinct buildings.

Pattern:
1. Write an ordered list of relaxations, each one keeping the steps before it: drop the floor rule, then lower the minimum size to 60%, then remove the rent cap.
2. Apply them one at a time until the list has N distinct buildings (dedupe by property, not by suite).
3. For each added candidate, compute its misses against the ORIGINAL constraints and store them in a free-form field (e.g. a checks dict) so you do not have to change a shared contract.
4. Rank everything under the loosest constraints you used, so the added candidates are not hard-excluded. Then stable-sort into three groups: strict fits, then relaxed, then excluded. Score order holds within each group.
5. Do the same sort in any re-rank path (e.g. rescore with new weights), or the relaxed sites drop out when weights change.
6. Keep downstream eligibility checks, such as a decision step or a lease options list, on the original constraints so a relaxed site is never chosen as the pick. Show a separator row and a Misses: label in the UI.
