(field: string, term: string)
| 138 | } |
| 139 | |
| 140 | function scoreTerm(field: string, term: string) { |
| 141 | const normalized = normalizeSearchText(field); |
| 142 | if (!normalized) return 0; |
| 143 | if (normalized === term) return 120; |
| 144 | if (normalized.startsWith(term)) return 100; |
| 145 | if (normalized.split(" ").some((word) => word.startsWith(term))) return 82; |
| 146 | |
| 147 | const index = normalized.indexOf(term); |
| 148 | if (index !== -1) return 64 - Math.min(index, 24); |
| 149 | |
| 150 | return fuzzySequenceScore(normalized, term); |
| 151 | } |
| 152 | |
| 153 | function scoreSearchItem(item: SearchIndexItem, query: string) { |
| 154 | const terms = normalizeSearchText(query).split(/\s+/).filter(Boolean); |
no test coverage detected