Commit e164b61
committed
fix(scoring): normalise key weights in object and keyless-logical search
_searchObjectList and the keyless branch of _searchLogical scored off
FuseIndex.keys, which holds the raw user-supplied weights. Only KeyStore
normalises weights to sum to 1, so large weights pushed
Math.pow(Number.EPSILON, weight * norm) to underflow to 0, and absolute
scores diverged between plain-string, keyed-logical, and keyless-logical
queries over identical data.
Add _normalizedKeys(), which resolves each index key to its normalised
KeyStore counterpart by id, kept aligned to positional item[keyIndex] so
a pre-built index whose key order differs from options.keys still scores
correctly. Use it in both scoring paths, matching how the keyed logical
path already reads from the KeyStore.
Result ordering is unchanged (normalised score = raw^(1/T) for a global
constant T); only absolute scores for weights that do not sum to 1 shift,
and underflow is eliminated.
Closes #8331 parent dbb98b6 commit e164b61
14 files changed
Lines changed: 185 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
993 | 993 | | |
994 | 994 | | |
995 | 995 | | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
996 | 999 | | |
997 | 1000 | | |
998 | 1001 | | |
| |||
1070 | 1073 | | |
1071 | 1074 | | |
1072 | 1075 | | |
1073 | | - | |
| 1076 | + | |
| 1077 | + | |
1074 | 1078 | | |
1075 | 1079 | | |
1076 | 1080 | | |
| |||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
992 | 992 | | |
993 | 993 | | |
994 | 994 | | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
995 | 998 | | |
996 | 999 | | |
997 | 1000 | | |
| |||
1069 | 1072 | | |
1070 | 1073 | | |
1071 | 1074 | | |
1072 | | - | |
| 1075 | + | |
| 1076 | + | |
1073 | 1077 | | |
1074 | 1078 | | |
1075 | 1079 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1374 | 1374 | | |
1375 | 1375 | | |
1376 | 1376 | | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
1377 | 1380 | | |
1378 | 1381 | | |
1379 | 1382 | | |
| |||
1447 | 1450 | | |
1448 | 1451 | | |
1449 | 1452 | | |
| 1453 | + | |
1450 | 1454 | | |
1451 | 1455 | | |
1452 | 1456 | | |
1453 | 1457 | | |
1454 | 1458 | | |
1455 | 1459 | | |
1456 | | - | |
| 1460 | + | |
1457 | 1461 | | |
1458 | 1462 | | |
1459 | 1463 | | |
| |||
1508 | 1512 | | |
1509 | 1513 | | |
1510 | 1514 | | |
1511 | | - | |
| 1515 | + | |
| 1516 | + | |
1512 | 1517 | | |
1513 | 1518 | | |
1514 | 1519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
338 | 339 | | |
339 | 340 | | |
340 | 341 | | |
| |||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1373 | 1373 | | |
1374 | 1374 | | |
1375 | 1375 | | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
1376 | 1379 | | |
1377 | 1380 | | |
1378 | 1381 | | |
| |||
1446 | 1449 | | |
1447 | 1450 | | |
1448 | 1451 | | |
| 1452 | + | |
1449 | 1453 | | |
1450 | 1454 | | |
1451 | 1455 | | |
1452 | 1456 | | |
1453 | 1457 | | |
1454 | 1458 | | |
1455 | | - | |
| 1459 | + | |
1456 | 1460 | | |
1457 | 1461 | | |
1458 | 1462 | | |
| |||
1507 | 1511 | | |
1508 | 1512 | | |
1509 | 1513 | | |
1510 | | - | |
| 1514 | + | |
| 1515 | + | |
1511 | 1516 | | |
1512 | 1517 | | |
1513 | 1518 | | |
| |||
0 commit comments