Skip to content

Commit

Permalink
Merge 78459aa into 8680ee7
Browse files Browse the repository at this point in the history
  • Loading branch information
ellnix committed Oct 10, 2023
2 parents 8680ee7 + 78459aa commit d3ca0de
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,9 @@ facet_search_2: |-
genres: 'count'
}
)
get_dictionary_1: |-
client.index('books').dictionary
update_dictionary_1: |-
client.index('books').update_dictionary(['J. R. R.', 'W. E. B.'])
reset_dictionary_1: |-
client.index('books').reset_dictionary
16 changes: 12 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-05-20 02:24:12 UTC using RuboCop version 1.50.2.
# on 2023-10-10 10:50:01 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.
Expand All @@ -14,16 +22,16 @@ Gemspec/RequireMFA:
Exclude:
- 'meilisearch.gemspec'

# Offense count: 47
# Offense count: 50
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 624
Max: 633

# Offense count: 2
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 328
Max: 338

# Offense count: 1
# Configuration parameters: Max, CountKeywordArgs.
Expand Down
15 changes: 15 additions & 0 deletions lib/meilisearch/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,5 +461,20 @@ def update_faceting(faceting_attributes)
def reset_faceting
http_delete("/indexes/#{@uid}/settings/faceting")
end

### SETTINGS - DICTIONARY

def dictionary
http_get("/indexes/#{@uid}/settings/dictionary")
end

def update_dictionary(dictionary_attributes)
attributes = Utils.transform_attributes(dictionary_attributes)
http_put("/indexes/#{@uid}/settings/dictionary", attributes)
end

def reset_dictionary
http_delete("/indexes/#{@uid}/settings/dictionary")
end
end
end
29 changes: 29 additions & 0 deletions spec/meilisearch/index/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -800,4 +800,33 @@ def update_synonyms(index, synonyms)
expect(index.faceting.transform_keys(&:to_sym).keys).to include(*default_faceting.keys)
end
end

context 'On user-defined dictionary' do
let(:index) { client.index(uid) }

before { client.create_index!(uid) }

it 'has no default value' do
settings = index.dictionary

expect(settings).to be_empty
end

it 'updates dictionary' do
update_task = index.update_dictionary(['J. R. R.', 'W. E. B.'])
client.wait_for_task(update_task['taskUid'])

expect(index.dictionary).to contain_exactly('J. R. R.', 'W. E. B.')
end

it 'resets dictionary' do
update_task = index.update_dictionary(['J. R. R.', 'W. E. B.'])
client.wait_for_task(update_task['taskUid'])

reset_task = index.reset_dictionary
client.wait_for_task(reset_task['taskUid'])

expect(index.dictionary).to be_empty
end
end
end

0 comments on commit d3ca0de

Please sign in to comment.