add server search logs

This commit is contained in:
SansGuidon 2025-05-18 00:17:26 +02:00
parent 851db0a673
commit 44be436d2d

View File

@ -14,7 +14,7 @@ function getWords(text) {
return text
.toLowerCase()
// Remove punctuation, keep letters, numbers, and whitespace. Handles Unicode.
.replace(/[^\p{L}\p{N}\s]/gu, '')
.replace(/[^\p{L}\p{N}\s]/gu, '')
.replace(/\s+/g, ' ') // Normalize multiple spaces to single
.trim()
.split(' ')
@ -33,6 +33,12 @@ app.get('/search', async (req, res) => {
filmages.searchAndEnrich(q).catch(e => { console.error('Filmages failed:', e.message); return []; })
]);
console.log('===== SEARCH LOGS =====');
console.log('Cinecheck results:', cine.length);
console.log('CSM results:', cs.length);
console.log('Filmages results:', fa.length);
console.log('Raw CSM data:', cs); // Inspect full data
let merged = mergeResults([cine, cs, fa]);
// Sort merged results based on query relevance
@ -51,7 +57,7 @@ app.get('/search', async (req, res) => {
}
item.matchScore1 = uniqueQueryWords.length > 0 ? commonWordCount / uniqueQueryWords.length : 0;
const unionLength = new Set([...uniqueQueryWords, ...uniqueTitleWords]).size;
item.matchScore2 = unionLength > 0 ? commonWordCount / unionLength : 0;
});
@ -62,7 +68,7 @@ app.get('/search', async (req, res) => {
return getWords(a.title).length - getWords(b.title).length; // Shorter titles preferred as tertiary sort
});
}
res.json(merged);
} catch (e) {
console.error('General search error:', e);