add server search logs
This commit is contained in:
parent
851db0a673
commit
44be436d2d
12
server.js
12
server.js
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user