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 => {