sorting with r!
This commit is contained in:
parent
4ca43f27cd
commit
b4fecdbe29
|
@ -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,16 +214,19 @@ function englishLookup<S extends T.DictionaryEntry>({ searchString, page, tpFilt
|
||||||
.simplesort("i")
|
.simplesort("i")
|
||||||
.data();
|
.data();
|
||||||
partialMatchResults.sort(sortByR);
|
partialMatchResults.sort(sortByR);
|
||||||
const results = [
|
const wordResults = [
|
||||||
...exactResults,
|
...exactResults,
|
||||||
...startingResults,
|
...startingResults,
|
||||||
...fullWordResults,
|
...fullWordResults,
|
||||||
|
];
|
||||||
|
wordResults.sort(sortByR);
|
||||||
|
const results = [
|
||||||
|
...wordResults,
|
||||||
...partialMatchResults,
|
...partialMatchResults,
|
||||||
];
|
];
|
||||||
if (tpFilter) {
|
if (tpFilter) {
|
||||||
return results.filter(tpFilter);
|
return results.filter(tpFilter);
|
||||||
}
|
}
|
||||||
console.log({ results });
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue