From 635d21524da960a5d800d3fb25744650bde3d9eb Mon Sep 17 00:00:00 2001 From: Morgan Wattiez Date: Sun, 25 May 2025 02:42:29 +0200 Subject: [PATCH] filter only movies matching query --- VERSION | 2 +- merge.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 1750564..5a5831a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.6 +0.0.7 diff --git a/merge.js b/merge.js index 7d5e406..ebe82f5 100644 --- a/merge.js +++ b/merge.js @@ -72,6 +72,17 @@ function mergeResults(arrays, query = '', limit = 5) { if (query) { out.forEach(f => f.__score = getMatchScore(f, query)); out = out.sort((a, b) => b.__score - a.__score); + + // PATCH: filter only films with ALL significant query words in title + const normQuery = query.trim().toLowerCase(); + const skip = new Set(['the','le','la','les','de','du','des','and','et','a','an','un','une','dans','en','on']); + const queryWords = normQuery.split(/\s+/).filter(w => w.length > 3 && !skip.has(w)); + if (queryWords.length) { + out = out.filter(film => { + const title = (film.title || '').toLowerCase(); + return queryWords.every(qw => title.includes(qw)); + }); + } } // Remove internals, trim to limit return out.slice(0, limit).map(f => {