Add custom sort function to improve search matching (#574)

This commit is contained in:
Chenlei Hu
2024-08-21 13:54:29 -04:00
committed by GitHub
parent 6edfc9bc1b
commit 77ba201367

View File

@@ -121,7 +121,13 @@ export class NodeSearchService {
includeScore: true,
threshold: 0.3,
shouldSort: true,
useExtendedSearch: true
useExtendedSearch: true,
// Sort by score first, then by length of the display name, then by index
// https://github.com/Comfy-Org/ComfyUI_frontend/issues/562#issuecomment-2299738393
sortFn: (a, b) =>
Math.abs(a.score - b.score) > 0.01
? a.score - b.score
: a.item[1]['v']['length'] - b.item[1]['v']['length'] || a.idx - b.idx
})
const filterSearchOptions = {