diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 9e86a242..9f6d2f29 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -647,6 +647,18 @@ update_proximity_precision_settings_1: |- client.index('books').update_proximity_precision('byAttribute') reset_proximity_precision_settings_1: |- client.index('books').reset_proximity_precision +get_facet_search_settings_1: |- + client.index('INDEX_UID').facet_search_setting +update_facet_search_settings_1: |- + client.index('INDEX_UID').update_facet_search_setting(false) +reset_facet_search_settings_1: |- + client.index('INDEX_UID').reset_facet_search_setting +get_prefix_search_settings_1: |- + client.index('INDEX_UID').prefix_search +update_prefix_search_settings_1: |- + client.index('INDEX_UID').update_prefix_search('disabled') +reset_prefix_search_settings_1: |- + client.index('INDEX_UID').reset_prefix_search get_search_cutoff_1: |- client.index('movies').search_cutoff_ms update_search_cutoff_1: |- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b06393f3..6090214c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,21 +1,21 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-01-02 22:29:58 UTC using RuboCop version 1.69.2. +# on 2025-01-08 15:54:24 UTC using RuboCop version 1.69.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: 64 +# Offense count: 66 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. # AllowedMethods: refine Metrics/BlockLength: - Max: 628 + Max: 670 # Offense count: 4 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 452 + Max: 470 # Offense count: 1 # Configuration parameters: Max, CountKeywordArgs. diff --git a/lib/meilisearch/index.rb b/lib/meilisearch/index.rb index b4b611fa..97d0a64f 100644 --- a/lib/meilisearch/index.rb +++ b/lib/meilisearch/index.rb @@ -645,5 +645,33 @@ def update_localized_attributes(new_localized_attributes) def reset_localized_attributes http_delete("/indexes/#{@uid}/settings/localized-attributes") end + + ### SETTINGS - FACET SEARCH + + def facet_search_setting + http_get("/indexes/#{@uid}/settings/facet-search") + end + + def update_facet_search_setting(new_facet_search_setting) + http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting) + end + + def reset_facet_search_setting + http_delete("/indexes/#{@uid}/settings/facet-search") + end + + ### SETTINGS - PREFIX SEARCH + + def prefix_search + http_get("/indexes/#{@uid}/settings/prefix-search") + end + + def update_prefix_search(new_prefix_search_setting) + http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting) + end + + def reset_prefix_search + http_delete("/indexes/#{@uid}/settings/prefix-search") + end end end diff --git a/spec/meilisearch/index/settings_spec.rb b/spec/meilisearch/index/settings_spec.rb index 5324807d..9636c31a 100644 --- a/spec/meilisearch/index/settings_spec.rb +++ b/spec/meilisearch/index/settings_spec.rb @@ -805,4 +805,64 @@ expect(index.localized_attributes).to eq(default_localized_attributes) end end + + context 'On facet search' do + let(:index) { client.index(uid) } + let(:default_facet_search_setting) { true } + + before { client.create_index(uid).await } + + it '#facet_search_setting gets default value' do + expect(index.facet_search_setting).to eq(default_facet_search_setting) + end + + it '#update_facet_search_setting updates default value' do + update_task = index.update_facet_search_setting(false) + client.wait_for_task(update_task['taskUid']) + + expect(index.facet_search_setting).to eq(false) + end + + it '#reset_facet_search_setting resets facet search' do + update_task = index.update_facet_search_setting(false) + client.wait_for_task(update_task['taskUid']) + + expect(index.facet_search_setting).to eq(false) + + reset_task = index.reset_facet_search_setting + client.wait_for_task(reset_task['taskUid']) + + expect(index.facet_search_setting).to eq(default_facet_search_setting) + end + end + + context 'On prefix search' do + let(:index) { client.index(uid) } + let(:default_prefix_search) { 'indexingTime' } + + before { client.create_index(uid).await } + + it '#prefix_search gets default value' do + expect(index.prefix_search).to eq(default_prefix_search) + end + + it '#update_prefix_search updates default value' do + update_task = index.update_prefix_search('disabled') + client.wait_for_task(update_task['taskUid']) + + expect(index.prefix_search).to eq('disabled') + end + + it '#reset_prefix_search resets prefix search' do + update_task = index.update_prefix_search('disabled') + client.wait_for_task(update_task['taskUid']) + + expect(index.prefix_search).to eq('disabled') + + reset_task = index.reset_prefix_search + client.wait_for_task(reset_task['taskUid']) + + expect(index.prefix_search).to eq(default_prefix_search) + end + end end