Skip to content

Commit

Permalink
Fix invalid sorting parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
ommann committed Mar 6, 2024
1 parent 96a6a4b commit 3fdc12f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/app/portal/services/publication2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,18 +1052,22 @@ function sortingTerms(searchParams: SearchParams) {
let sortedField = "publicationYear";
let direction = "desc";

const textFields = ["publicationName", "authorsText", "publisherName"];

if (searchParams.sort != null) {
const value = searchParams.sort.pop();

sortedField = value.replace(/Desc$/, "");
direction = value.endsWith("Desc") ? "desc" : "asc";

sortedField += ".keyword";
if (textFields.includes(sortedField)) {
sortedField += ".keyword";
}
}

return [
"_score",
{ [sortedField]: { "order": direction } }
{ [sortedField]: { "order": direction } },
"_score"
];
}

Expand Down

0 comments on commit 3fdc12f

Please sign in to comment.