From 4183df2aed5f44f0d474fbd9b02301b53ac92819 Mon Sep 17 00:00:00 2001 From: Andre <> Date: Tue, 2 Jul 2024 23:05:48 +0200 Subject: [PATCH 1/3] Tests added for rankingScoreThreshold --- .code-samples.meilisearch.yaml | 4 ++++ .../index/search/ranking_score_threshold_spec.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 spec/meilisearch/index/search/ranking_score_threshold_spec.rb diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 4984951f..9d080ae4 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -653,3 +653,7 @@ 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('movies').search('badman', { + rankingScoreThreshold: 0.2 + }) diff --git a/spec/meilisearch/index/search/ranking_score_threshold_spec.rb b/spec/meilisearch/index/search/ranking_score_threshold_spec.rb new file mode 100644 index 00000000..29cb8cd0 --- /dev/null +++ b/spec/meilisearch/index/search/ranking_score_threshold_spec.rb @@ -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 chamber of secrets', { 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(1) + end +end From e7ef719b9462e93cb807906ae907e08e0bb95be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine?= Date: Sat, 6 Jul 2024 18:00:26 +0200 Subject: [PATCH 2/3] Update .code-samples.meilisearch.yaml --- .code-samples.meilisearch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 9d080ae4..681e2a95 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -654,6 +654,6 @@ update_search_cutoff_1: |- reset_search_cutoff_1: |- client.index('movies').reset_search_cutoff_ms search_parameter_reference_ranking_score_threshold_1: |- - client.index('movies').search('badman', { + client.index('INDEX_NAME').search('badman', { rankingScoreThreshold: 0.2 }) From e753f456ea35550588c31c5e2b505c1071e37a8e Mon Sep 17 00:00:00 2001 From: Andre <> Date: Sat, 6 Jul 2024 18:37:28 +0200 Subject: [PATCH 3/3] Tests fixed --- spec/meilisearch/index/search/ranking_score_threshold_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/meilisearch/index/search/ranking_score_threshold_spec.rb b/spec/meilisearch/index/search/ranking_score_threshold_spec.rb index 29cb8cd0..7d25e94f 100644 --- a/spec/meilisearch/index/search/ranking_score_threshold_spec.rb +++ b/spec/meilisearch/index/search/ranking_score_threshold_spec.rb @@ -4,10 +4,10 @@ include_context 'search books with genre' it 'does a custom search with rankingScoreThreshold' do - response = index.search('harry potter and the chamber of secrets', { rankingScoreThreshold: 0.9 }) + 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(1) + expect(response['hits'].count).to be(2) end end