Sort then slice
This commit is contained in:
@@ -130,9 +130,7 @@
|
|||||||
|
|
||||||
async function updateResults() {
|
async function updateResults() {
|
||||||
query = new Query(searchQuery)
|
query = new Query(searchQuery)
|
||||||
resultNotes = (await searchEngine.getSuggestions(query)).sort(
|
resultNotes = await searchEngine.getSuggestions(query)
|
||||||
(a, b) => b.score - a.score
|
|
||||||
)
|
|
||||||
selectedIndex = 0
|
selectedIndex = 0
|
||||||
await scrollIntoView()
|
await scrollIntoView()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,7 +247,8 @@ export class Omnisearch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results = results.slice(0, 50)
|
// Sort results and keep the 50 best
|
||||||
|
results = results.sort((a, b) => b.score - a.score).slice(0, 50)
|
||||||
|
|
||||||
const documents = await Promise.all(
|
const documents = await Promise.all(
|
||||||
results.map(async result => await cacheManager.getDocument(result.id))
|
results.map(async result => await cacheManager.getDocument(result.id))
|
||||||
|
|||||||
Reference in New Issue
Block a user