fix(badges): support multi-word fulltext search
- Split search query by spaces - Apply AND logic: all words must match - Single word: LIKE '%word%' - Multi-word: LIKE '%word1%' AND LIKE '%word2%' Example: 'scott idem' now searches for both 'scott' AND 'idem' Previously searched for literal 'scott idem' phrase which failed. Fixes search bug discovered during Playwright test development.
This commit is contained in:
@@ -403,9 +403,21 @@ export async function search__event_badge({
|
||||
|
||||
// Standardized Text Search Pattern (V3 API)
|
||||
// NOTE: Using 'default_qry_str' (Strict DB Column)
|
||||
// Multi-word support: Split query by spaces and search for all words (AND logic)
|
||||
if (fulltext_search_qry_str && fulltext_search_qry_str.trim().length > 0) {
|
||||
const qry = fulltext_search_qry_str.trim();
|
||||
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry}%` });
|
||||
const words = qry.split(/\s+/).filter(w => w.length > 0);
|
||||
|
||||
if (words.length === 1) {
|
||||
// Single word: use simple LIKE
|
||||
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${words[0]}%` });
|
||||
} else if (words.length > 1) {
|
||||
// Multiple words: each word must match (AND logic)
|
||||
for (const word of words) {
|
||||
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${word}%` });
|
||||
}
|
||||
}
|
||||
|
||||
params['lk_qry'] = params['lk_qry'] || {};
|
||||
params['lk_qry']['default_qry_str'] = qry;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user