Skip to content

Commit

Permalink
Merge #550
Browse files Browse the repository at this point in the history
550: Add code sample and tests for rankingScoreThreshold search parameter r=curquiza a=andre-m-dev

# Pull Request

## Related issue
Fixes #544

## What does this PR do?
rankingScoreThreshold implemented

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?


Co-authored-by: Andre <>
Co-authored-by: Clémentine <[email protected]>
  • Loading branch information
meili-bors[bot] and curquiza authored Jul 6, 2024
2 parents 5d4e3ed + e753f45 commit b8d3de2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,10 @@ update_search_cutoff_1: |-
client.index('movies').update_search_cutoff_ms(150)
reset_search_cutoff_1: |-
client.index('movies').reset_search_cutoff_ms
search_parameter_reference_ranking_score_threshold_1: |-
client.index('INDEX_NAME').search('badman', {
rankingScoreThreshold: 0.2
})
search_parameter_reference_distinct_1: |-
client.index('INDEX_NAME').search('QUERY TERMS', {
distinct: 'ATTRIBUTE_A'
Expand Down
13 changes: 13 additions & 0 deletions spec/meilisearch/index/search/ranking_score_threshold_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

RSpec.describe 'MeiliSearch::Index - Search with rankingScoreThreshold' do
include_context 'search books with genre'

it 'does a custom search with rankingScoreThreshold' do
response = index.search('harry potter and the prisoner of azkaban', { rankingScoreThreshold: 0.9 })
expect(response['hits'].count).to be(0)

response = index.search('harry potter and the', { rankingScoreThreshold: 0.3 })
expect(response['hits'].count).to be(2)
end
end

0 comments on commit b8d3de2

Please sign in to comment.