From ee6a99b9c1808847145c40d65406ab593805cad8 Mon Sep 17 00:00:00 2001 From: ellnix <103502144+ellnix@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:40:16 +0200 Subject: [PATCH 1/7] Add separator_tokens, non_separator_tokens specs --- spec/meilisearch/index/settings_spec.rb | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/spec/meilisearch/index/settings_spec.rb b/spec/meilisearch/index/settings_spec.rb index b52bb218..61b0861f 100644 --- a/spec/meilisearch/index/settings_spec.rb +++ b/spec/meilisearch/index/settings_spec.rb @@ -829,4 +829,56 @@ def update_synonyms(index, synonyms) expect(index.dictionary).to be_empty end end + + context 'On separator tokens' do + let(:index) { client.index(uid) } + + before { client.create_index!(uid) } + + describe 'separator_tokens' do + it 'has no default value' do + expect(index.separator_tokens).to be_empty + end + + it 'updates separator tokens' do + update_task = index.update_separator_tokens ['|', '…'] + client.wait_for_task(update_task['taskUid']) + + expect(index.separator_tokens).to contain_exactly('|', '…') + end + + it 'resets separator tokens' do + update_task = index.update_separator_tokens ['|', '…'] + client.wait_for_task(update_task['taskUid']) + + reset_task = index.reset_separator_tokens + client.wait_for_task(reset_task['taskUid']) + + expect(index.separator_tokens).to be_empty + end + end + + describe 'non_separator_tokens' do + it 'has no default value' do + expect(index.non_separator_tokens).to be_empty + end + + it 'updates non separator tokens' do + update_task = index.update_non_separator_tokens ['@', '#'] + client.wait_for_task(update_task['taskUid']) + + expect(index.non_separator_tokens).to contain_exactly('@', '#') + end + + it 'resets non separator tokens' do + update_task = index.update_non_separator_tokens ['@', '#'] + client.wait_for_task(update_task['taskUid']) + + reset_task = index.reset_non_separator_tokens + client.wait_for_task(reset_task['taskUid']) + + expect(index.non_separator_tokens).to be_empty + end + end + end end From ebc9af2610b619615ea8a726cfb7e39222b13676 Mon Sep 17 00:00:00 2001 From: ellnix <103502144+ellnix@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:53:55 +0200 Subject: [PATCH 2/7] Add non_separator_tokens, separator_tokens methods --- lib/meilisearch/index.rb | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/meilisearch/index.rb b/lib/meilisearch/index.rb index 5b4e71ce..3486657a 100644 --- a/lib/meilisearch/index.rb +++ b/lib/meilisearch/index.rb @@ -476,5 +476,38 @@ def update_dictionary(dictionary_attributes) def reset_dictionary http_delete("/indexes/#{@uid}/settings/dictionary") end + ### SETTINGS - SEPARATOR TOKENS + + def separator_tokens + http_get("/indexes/#{@uid}/settings/separator-tokens") + end + alias get_separator_tokens separator_tokens + + def update_separator_tokens(separator_tokens_attributes) + attributes = Utils.transform_attributes(separator_tokens_attributes) + http_put("/indexes/#{@uid}/settings/separator-tokens", attributes) + end + alias separator_tokens= update_separator_tokens + + def reset_separator_tokens + http_delete("/indexes/#{@uid}/settings/separator-tokens") + end + + ### SETTINGS - NON SEPARATOR TOKENS + + def non_separator_tokens + http_get("/indexes/#{@uid}/settings/non-separator-tokens") + end + alias get_non_separator_tokens non_separator_tokens + + def update_non_separator_tokens(non_separator_tokens_attributes) + attributes = Utils.transform_attributes(non_separator_tokens_attributes) + http_put("/indexes/#{@uid}/settings/non-separator-tokens", attributes) + end + alias non_separator_tokens= update_non_separator_tokens + + def reset_non_separator_tokens + http_delete("/indexes/#{@uid}/settings/non-separator-tokens") + end end end From ce337f36974792928cde11ab420a7485358dfc5d Mon Sep 17 00:00:00 2001 From: ellnix <103502144+ellnix@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:57:37 +0200 Subject: [PATCH 3/7] Add (non_)separator_tokens to .code-samples --- .code-samples.meilisearch.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index ad238f64..9cf60aee 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -615,3 +615,15 @@ update_dictionary_1: |- client.index('books').update_dictionary(['J. R. R.', 'W. E. B.']) reset_dictionary_1: |- client.index('books').reset_dictionary +get_separator_tokens_1: |- + client.index('articles').separator_tokens +update_separator_tokens_1: |- + client.index('articles').update_separator_tokens(['|', '…']) +reset_separator_tokens_1: |- + client.index('articles').reset_separator_tokens +get_non_separator_tokens_1: |- + client.index('articles').non_separator_tokens +update_non_separator_tokens_1: |- + client.index('articles').update_non_separator_tokens(['@', '#']) +reset_non_separator_tokens_1: |- + client.index('articles').reset_non_separator_tokens From 9f148e381632df23dbc8e9c362337b388966c4d3 Mon Sep 17 00:00:00 2001 From: ellnix <103502144+ellnix@users.noreply.github.com> Date: Fri, 6 Oct 2023 17:37:21 +0200 Subject: [PATCH 4/7] Remove unnecessary separator token getter aliases --- lib/meilisearch/index.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/meilisearch/index.rb b/lib/meilisearch/index.rb index 3486657a..69ae73aa 100644 --- a/lib/meilisearch/index.rb +++ b/lib/meilisearch/index.rb @@ -481,7 +481,6 @@ def reset_dictionary def separator_tokens http_get("/indexes/#{@uid}/settings/separator-tokens") end - alias get_separator_tokens separator_tokens def update_separator_tokens(separator_tokens_attributes) attributes = Utils.transform_attributes(separator_tokens_attributes) @@ -498,7 +497,6 @@ def reset_separator_tokens def non_separator_tokens http_get("/indexes/#{@uid}/settings/non-separator-tokens") end - alias get_non_separator_tokens non_separator_tokens def update_non_separator_tokens(non_separator_tokens_attributes) attributes = Utils.transform_attributes(non_separator_tokens_attributes) From 684d414296be162f4d0d949e32491dbd0bf52f91 Mon Sep 17 00:00:00 2001 From: ellnix <103502144+ellnix@users.noreply.github.com> Date: Sat, 7 Oct 2023 14:34:28 +0200 Subject: [PATCH 5/7] Remove unnecessary separator token setter aliases --- lib/meilisearch/index.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/meilisearch/index.rb b/lib/meilisearch/index.rb index 69ae73aa..df5d5e99 100644 --- a/lib/meilisearch/index.rb +++ b/lib/meilisearch/index.rb @@ -486,7 +486,6 @@ def update_separator_tokens(separator_tokens_attributes) attributes = Utils.transform_attributes(separator_tokens_attributes) http_put("/indexes/#{@uid}/settings/separator-tokens", attributes) end - alias separator_tokens= update_separator_tokens def reset_separator_tokens http_delete("/indexes/#{@uid}/settings/separator-tokens") @@ -502,7 +501,6 @@ def update_non_separator_tokens(non_separator_tokens_attributes) attributes = Utils.transform_attributes(non_separator_tokens_attributes) http_put("/indexes/#{@uid}/settings/non-separator-tokens", attributes) end - alias non_separator_tokens= update_non_separator_tokens def reset_non_separator_tokens http_delete("/indexes/#{@uid}/settings/non-separator-tokens") From cedbaab1a03efa1dc25b270084c429a1bae1f0b6 Mon Sep 17 00:00:00 2001 From: Bruno Casali Date: Mon, 9 Oct 2023 15:55:57 +0200 Subject: [PATCH 6/7] Update spec/meilisearch/index/settings_spec.rb --- spec/meilisearch/index/settings_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/meilisearch/index/settings_spec.rb b/spec/meilisearch/index/settings_spec.rb index 61b0861f..cac99242 100644 --- a/spec/meilisearch/index/settings_spec.rb +++ b/spec/meilisearch/index/settings_spec.rb @@ -858,7 +858,7 @@ def update_synonyms(index, synonyms) end end - describe 'non_separator_tokens' do + describe '#non_separator_tokens' do it 'has no default value' do expect(index.non_separator_tokens).to be_empty end From c8f6fe5b19d9ba9988cf95f461e605d0e5b66cf3 Mon Sep 17 00:00:00 2001 From: ellnix <103502144+ellnix@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:02:14 +0200 Subject: [PATCH 7/7] Re-generate .rubocop_todo.yml --- .rubocop_todo.yml | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bb2ab4a6..1154e166 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,37 +1,21 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-10-10 10:50:01 UTC using RuboCop version 1.50.2. +# on 2023-10-10 14:01:22 UTC using RuboCop version 1.50.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemfile, **/Gemfile, **/gems.rb -Bundler/OrderedGems: - Exclude: - - 'Gemfile' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec -Gemspec/RequireMFA: - Exclude: - - 'meilisearch.gemspec' - -# Offense count: 50 +# Offense count: 52 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. # AllowedMethods: refine Metrics/BlockLength: - Max: 633 + Max: 671 # Offense count: 2 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 338 + Max: 358 # Offense count: 1 # Configuration parameters: Max, CountKeywordArgs.