Commit 073d260
authored
fix(search): match multi-word FTS queries (#306)
* fix(search): match multi-word FTS queries
Replace blanket phrase-wrapping in _sanitize_fts5_query with tokenize ->
drop stopwords/operators -> quote each term -> OR. Multi-word queries
(every query the agent sends for papers/discussions/FAQ/docstrings) were
exact-phrase matched and returned nothing despite populated databases.
Still injection-safe (each term individually quoted); results ordered by
existing BM25 rank. Affects all 6 knowledge-search call sites.
Closes #305
* test(search): harden operator test; keep list/use terms
Address PR review:
- strengthen test_sanitize_fts5_operators to assert every term is
individually quoted (no bare operator can reach MATCH)
- drop 'list' and 'use' from stopwords (meaningful EEGLAB/MATLAB nouns)
so multi-word queries like 'list channels' don't silently lose a term
* test(bep): use non-matching query for no-results case
BEP keyword search is OR-based and rank-ordered after the FTS fix, so the
old phrase-only no-match query ('...data type...') now matches BEPs that
mention 'data'. Use a genuinely non-matching query to keep the
no-results path covered.1 parent 72199ba commit 073d260
3 files changed
Lines changed: 165 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
101 | 175 | | |
102 | | - | |
| 176 | + | |
103 | 177 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
107 | 183 | | |
108 | | - | |
109 | | - | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
110 | 187 | | |
111 | 188 | | |
112 | 189 | | |
113 | 190 | | |
114 | 191 | | |
115 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
116 | 196 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
121 | 207 | | |
122 | 208 | | |
123 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
171 | 172 | | |
172 | 173 | | |
173 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
174 | 197 | | |
175 | 198 | | |
176 | 199 | | |
| |||
317 | 340 | | |
318 | 341 | | |
319 | 342 | | |
320 | | - | |
321 | | - | |
| 343 | + | |
| 344 | + | |
322 | 345 | | |
323 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
324 | 360 | | |
325 | | - | |
326 | | - | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
327 | 369 | | |
328 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
329 | 377 | | |
330 | 378 | | |
331 | | - | |
| 379 | + | |
332 | 380 | | |
333 | 381 | | |
334 | 382 | | |
| |||
339 | 387 | | |
340 | 388 | | |
341 | 389 | | |
342 | | - | |
343 | | - | |
344 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
345 | 399 | | |
346 | 400 | | |
347 | 401 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
126 | 129 | | |
127 | 130 | | |
128 | 131 | | |
| |||
0 commit comments