Skip to content

Commit

Permalink
Implement the proximity precision option so that you can set it throu…
Browse files Browse the repository at this point in the history
…gh a model file

- good when you prefer shorter indexing time to higher search precision
- https://www.meilisearch.com/docs/reference/api/settings#proximity-precision
  • Loading branch information
KatsukiFujimoto committed Apr 8, 2024
1 parent 9f71936 commit b05073a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/meilisearch-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class IndexSettings
pagination
faceting
typo_tolerance
proximity_precision
].freeze

CAMELIZE_OPTIONS = %i[pagination faceting typo_tolerance].freeze
Expand Down
36 changes: 36 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1235,3 +1235,39 @@ def self.name
end
end
end

describe 'proximity_precision' do
before do
stub_const(
'OtherColor',
Class.new do
include ActiveModel::Model
include MeiliSearch::Rails
end
)
end

context 'when the value is byWord' do
before do
OtherColor.meilisearch synchronize: true, index_uid: safe_index_uid('OtherColors') do
proximity_precision 'byWord'
end
end

it 'sets the value byWord to proximity precision' do
expect(OtherColor.index.get_settings['proximityPrecision']).to eq('byWord')
end
end

context 'when the value is byAttribute' do
before do
OtherColor.meilisearch synchronize: true, index_uid: safe_index_uid('OtherColors') do
proximity_precision 'byAttribute'
end
end

it 'sets the value byAttribute to proximity precision' do
expect(OtherColor.index.get_settings['proximityPrecision']).to eq('byAttribute')
end
end
end

0 comments on commit b05073a

Please sign in to comment.