improvements to similar notes - now using dice's coefficient for better results

This commit is contained in:
zadam
2019-09-01 11:33:45 +02:00
parent 0e867a995f
commit 55356963dd
5 changed files with 104 additions and 19 deletions

View File

@@ -12,11 +12,14 @@ async function getSimilarNotes(req) {
return [404, `Note ${noteId} not found.`];
}
const results = await noteCacheService.findNotes(note.title);
const start = new Date();
const results = await noteCacheService.findSimilarNotes(note.title);
console.log("Similar note took: " + (Date.now() - start.getTime()) + "ms");
return results
.map(r => r.noteId)
.filter(similarNoteId => similarNoteId !== noteId);
.filter(note => note.noteId !== noteId);
}
module.exports = {