Skip to content

Commit

Permalink
Merge c8f6fe5 into c73ad5e
Browse files Browse the repository at this point in the history
  • Loading branch information
ellnix authored Oct 10, 2023
2 parents c73ad5e + c8f6fe5 commit fe533a4
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 20 deletions.
12 changes: 12 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 4 additions & 20 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
29 changes: 29 additions & 0 deletions lib/meilisearch/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -476,5 +476,34 @@ 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

def update_separator_tokens(separator_tokens_attributes)
attributes = Utils.transform_attributes(separator_tokens_attributes)
http_put("/indexes/#{@uid}/settings/separator-tokens", attributes)
end

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

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

def reset_non_separator_tokens
http_delete("/indexes/#{@uid}/settings/non-separator-tokens")
end
end
end
52 changes: 52 additions & 0 deletions spec/meilisearch/index/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fe533a4

Please sign in to comment.