Skip to content

Commit

Permalink
Fixes searching for 'Record Editor' (#1240)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbastn authored Sep 3, 2024
1 parent 3bae18f commit 3b0b1a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions templates/search.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var articleScore = function articleScore (article, q) {
if (article.searchTitle.indexOf(q) !== -1)
score += 75;

if (article.searchTitle === q)
score += 50;

if (article.searchBody.indexOf(q) !== -1)
score += 50;

Expand Down Expand Up @@ -93,13 +96,13 @@ var findByScore = function findByScore (q, articles) {
article.score = articleScore(article, q);
return article.score > MIN_SCORE;
})
.filter(function (article, index) {
return index <= MAX_RESULTS;
})
.sort(function (a, b) {
if (a.score > b.score) return -1;
if (a.score < b.score) return 1;
return 0;
})
.filter(function (article, index) {
return index <= MAX_RESULTS;
});
};

Expand Down

0 comments on commit 3b0b1a7

Please sign in to comment.