Skip to content

Commit

Permalink
fix(threshold): fixes threshold length calculation (askorama#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva authored Apr 25, 2023
1 parent 305d15b commit beb5ef2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/orama/src/components/algorithms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function prioritizeTokenScores(arrays: TokenScore[][], boost: number, thr
// (fuzzy match with a minimum threshold)
const thresholdLength = Math.ceil((threshold * 100 * results.length) / 100)

return results.slice(0, thresholdLength)
return results.slice(0, results.length + thresholdLength)
}

export function BM25(
Expand Down
2 changes: 1 addition & 1 deletion packages/orama/tests/threshold.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ t.test('should return all the exact matches + X% of the partial matches', async
threshold: 0.7,
})

t.same(r1.count, 3)
t.same(r1.count, 4)
t.same(r2.count, 3)
})

0 comments on commit beb5ef2

Please sign in to comment.