Update search_kws rule for tantivy

This commit is contained in:
2026-06-23 08:30:07 +08:00
parent 8f8d12a5e7
commit 333f2cff43

View File

@@ -207,16 +207,20 @@ export class HighlightedMarkdown extends Component {
['nickname', NICKNAME_RE], ['nickname', NICKNAME_RE],
]; ];
if (props.search_param) { if (props.search_param) {
let search_kws = props.search_param.split(' ').filter((s) => !!s); let search_kws = props.search_param
rules.push([ .split(/[\s()+-]+/)
'search', .filter((s) => s && s !== 'AND' && s !== 'OR');
new RegExp( if (search_kws.length) {
`(${search_kws rules.push([
.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')) 'search',
.join('|')})`, new RegExp(
'g', `(${search_kws
), .map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
]); .join('|')})`,
'g',
),
]);
}
} }
const splitted = split_text(originalText, rules); const splitted = split_text(originalText, rules);