Skip to content

Commit 82589d2

Browse files
Try #512:
2 parents ed4dc30 + ec31baa commit 82589d2

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

.code-samples.meilisearch.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,3 +631,9 @@ update_non_separator_tokens_1: |-
631631
client.index('articles').update_non_separator_tokens(['@', '#'])
632632
reset_non_separator_tokens_1: |-
633633
client.index('articles').reset_non_separator_tokens
634+
get_proximity_precision_settings_1: |-
635+
client.index('books').proximity_precision
636+
update_proximity_precision_settings_1: |-
637+
client.index('books').update_proximity_precision('byAttribute')
638+
reset_proximity_precision_settings_1: |-
639+
client.index('books').reset_proximity_precision

.rubocop_todo.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2023-10-11 10:43:57 UTC using RuboCop version 1.50.2.
3+
# on 2024-01-16 21:52:52 UTC using RuboCop version 1.50.2.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -10,12 +10,12 @@
1010
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
1111
# AllowedMethods: refine
1212
Metrics/BlockLength:
13-
Max: 671
13+
Max: 694
1414

1515
# Offense count: 2
1616
# Configuration parameters: CountComments, CountAsOne.
1717
Metrics/ClassLength:
18-
Max: 363
18+
Max: 373
1919

2020
# Offense count: 1
2121
# Configuration parameters: Max, CountKeywordArgs.

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ gemspec
99

1010
group :development, :test do
1111
gem 'byebug'
12+
gem 'codecov'
1213
gem 'rspec', '~> 3.0'
1314
gem 'simplecov'
14-
gem 'codecov'
1515

1616
# Used only for testing, none of the classes are exposed to the public API.
1717
gem 'jwt'

lib/meilisearch/index.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,5 +514,19 @@ def update_non_separator_tokens(non_separator_tokens_attributes)
514514
def reset_non_separator_tokens
515515
http_delete("/indexes/#{@uid}/settings/non-separator-tokens")
516516
end
517+
518+
### SETTINGS - PROXIMITY PRECISION
519+
520+
def proximity_precision
521+
http_get("/indexes/#{@uid}/settings/proximity-precision")
522+
end
523+
524+
def update_proximity_precision(proximity_precision_attribute)
525+
http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
526+
end
527+
528+
def reset_proximity_precision
529+
http_delete("/indexes/#{@uid}/settings/proximity-precision")
530+
end
517531
end
518532
end

spec/meilisearch/index/settings_spec.rb

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
let(:default_searchable_attributes) { ['*'] }
1515
let(:default_displayed_attributes) { ['*'] }
1616
let(:default_pagination) { { maxTotalHits: 1000 } }
17+
let(:default_proximity_precision) { 'byWord' }
1718
let(:settings_keys) do
1819
[
1920
'rankingRules',
@@ -29,7 +30,8 @@
2930
'pagination',
3031
'dictionary',
3132
'nonSeparatorTokens',
32-
'separatorTokens'
33+
'separatorTokens',
34+
'proximityPrecision'
3335
]
3436
end
3537
let(:uid) { random_uid }
@@ -52,6 +54,7 @@
5254
expect(settings['pagination'].transform_keys(&:to_sym)).to eq(default_pagination)
5355
expect(settings['filterableAttributes']).to eq([])
5456
expect(settings['sortableAttributes']).to eq([])
57+
expect(settings['proximityPrecision']).to eq(default_proximity_precision)
5558
end
5659

5760
it 'updates multiples settings at the same time' do
@@ -85,7 +88,8 @@
8588
ranking_rules: ['title:asc', 'typo'],
8689
distinct_attribute: 'title',
8790
stop_words: ['the', 'a'],
88-
synonyms: { wow: ['world of warcraft'] }
91+
synonyms: { wow: ['world of warcraft'] },
92+
proximity_precision: 'byAttribute'
8993
)
9094
client.wait_for_task(task['taskUid'])
9195

@@ -99,6 +103,7 @@
99103
expect(settings['distinctAttribute']).to be_nil
100104
expect(settings['stopWords']).to be_empty
101105
expect(settings['synonyms']).to be_empty
106+
expect(settings['proximityPrecision']).to eq(default_proximity_precision)
102107
end
103108
end
104109

@@ -880,5 +885,28 @@ def update_synonyms(index, synonyms)
880885
expect(index.non_separator_tokens).to be_empty
881886
end
882887
end
888+
889+
describe '#proximity_precision' do
890+
it 'has byWord as default value' do
891+
expect(index.proximity_precision).to eq('byWord')
892+
end
893+
894+
it 'updates proximity precision' do
895+
update_task = index.update_proximity_precision('byAttribute')
896+
client.wait_for_task(update_task['taskUid'])
897+
898+
expect(index.proximity_precision).to eq('byAttribute')
899+
end
900+
901+
it 'resets proximity precision' do
902+
update_task = index.update_proximity_precision('byAttribute')
903+
client.wait_for_task(update_task['taskUid'])
904+
905+
reset_task = index.reset_proximity_precision
906+
client.wait_for_task(reset_task['taskUid'])
907+
908+
expect(index.proximity_precision).to eq('byWord')
909+
end
910+
end
883911
end
884912
end

0 commit comments

Comments
 (0)