When multiple tickets match the same confirmation number, rank them so the most recent and relevant ticket appears first.
The ranking gives highest priority to when the ticket was created, while also considering recent activity and whether the ticket is still open.
For N matching tickets:
-
Sort tickets by
created_at, newest first.- Assign score from
Nto1. - The newest ticket gets the highest score.
- Assign score from
-
Sort tickets by
updated_at, newest first.- Assign half-weight score from
N * 0.5to0.5.
- Assign half-weight score from
-
Add a status bonus.
- Open ticket:
+0.5 - Closed ticket:
+0
- Open ticket:
final_score = created_score + updated_score + status_bonus
The ticket with the highest final_score is selected as the best match.
Assume 5 tickets are found:
| Ticket | Created Rank | Created Score | Updated Rank | Updated Score | Status | Status Bonus | Final Score |
|---|---|---|---|---|---|---|---|
| A | 1 | 5 | 3 | 1.5 | Closed | 0 | 6.5 |
| B | 2 | 4 | 1 | 2.5 | Open | 0.5 | 7.0 |
| C | 3 | 3 | 2 | 2.0 | Closed | 0 | 5.0 |
| D | 4 | 2 | 5 | 0.5 | Open | 0.5 | 3.0 |
| E | 5 | 1 | 4 | 1.0 | Closed | 0 | 2.0 |
Ticket B is selected.
Even though Ticket A was created most recently, Ticket B has more recent activity and is still open, so it becomes the stronger candidate.