Commit 3692c62
committed
add relevance scoring for single-field prefix searches
Improvements:
- Single-field prefix searches now sort by field length (shorter = more relevant)
- Exact matches like "Wilma" will appear before longer matches like "Wilmaaaa"
- Uses LENGTH() function which is compatible across MySQL, PostgreSQL, and SQLite
Technical details:
- Added orderByRaw("LENGTH({$field}) ASC") to scopeEncryptedPrefix
- Multi-field searches remain unsorted due to database function compatibility
- For best results with sorted relevance, use single-field prefix searches
Example:
Client::encryptedPrefix('first_names', 'Wilma')->get()
// Returns: Wilma, Wilmar, Wilmaaaa (sorted by length)1 parent 875c515 commit 3692c62
1 file changed
+5
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
| 352 | + | |
| 353 | + | |
353 | 354 | | |
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
358 | 359 | | |
359 | 360 | | |
360 | | - | |
| 361 | + | |
361 | 362 | | |
362 | 363 | | |
363 | 364 | | |
| |||
408 | 409 | | |
409 | 410 | | |
410 | 411 | | |
| 412 | + | |
| 413 | + | |
411 | 414 | | |
412 | 415 | | |
413 | 416 | | |
| |||
0 commit comments