This commit is contained in:
adueck 2022-11-25 20:39:35 +05:00
parent b4fecdbe29
commit f140e39f8b
1 changed files with 4 additions and 8 deletions

View File

@ -167,7 +167,7 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
.limit(exactResultsLimit) .limit(exactResultsLimit)
.simplesort("i") .simplesort("i")
.data(); .data();
// exactResults.sort(sortByR); exactResults.sort(sortByR);
resultsGiven = exactResults.map((mpd: any) => mpd.$loki); resultsGiven = exactResults.map((mpd: any) => mpd.$loki);
// get results with full word match at beginning of string // get results with full word match at beginning of string
const startingQuery = { const startingQuery = {
@ -182,7 +182,7 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
.limit(startingResultsLimit) .limit(startingResultsLimit)
.simplesort("i") .simplesort("i")
.data(); .data();
// startingResults.sort(sortByR); startingResults.sort(sortByR);
resultsGiven = [...resultsGiven, ...startingResults.map((mpd: any) => mpd.$loki)]; resultsGiven = [...resultsGiven, ...startingResults.map((mpd: any) => mpd.$loki)];
// get results with full word match anywhere // get results with full word match anywhere
const fullWordQuery = { const fullWordQuery = {
@ -197,7 +197,7 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
.limit(fullWordResultsLimit) .limit(fullWordResultsLimit)
.simplesort("i") .simplesort("i")
.data(); .data();
// fullWordResults.sort(sortByR); fullWordResults.sort(sortByR);
resultsGiven = [...resultsGiven, ...fullWordResults.map((mpd: any) => mpd.$loki)] resultsGiven = [...resultsGiven, ...fullWordResults.map((mpd: any) => mpd.$loki)]
// get results with partial match anywhere // get results with partial match anywhere
const partialMatchQuery = { const partialMatchQuery = {
@ -214,14 +214,10 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
.simplesort("i") .simplesort("i")
.data(); .data();
partialMatchResults.sort(sortByR); partialMatchResults.sort(sortByR);
const wordResults = [ const results = [
...exactResults, ...exactResults,
...startingResults, ...startingResults,
...fullWordResults, ...fullWordResults,
];
wordResults.sort(sortByR);
const results = [
...wordResults,
...partialMatchResults, ...partialMatchResults,
]; ];
if (tpFilter) { if (tpFilter) {