From 71eb1e3571c50d7e6de99ccab68c9386668f40b5 Mon Sep 17 00:00:00 2001 From: ellnix Date: Fri, 3 Jan 2025 13:25:58 +0100 Subject: [PATCH 1/4] Add tests for prefix and facet search settings --- spec/meilisearch/index/settings_spec.rb | 60 +++++++++++++++++++++++++ 1 file changed, 60 insertions(+) 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 From 7b8aa79db4474c0ebcbb92c39870391fbe28ad49 Mon Sep 17 00:00:00 2001 From: ellnix Date: Fri, 3 Jan 2025 13:26:19 +0100 Subject: [PATCH 2/4] Add setters and getters for prefix and facet search Appended "_setting" to all facet search settings to avoid collisions with the `facet_search` method and avoid confusion. --- lib/meilisearch/index.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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 From 46239fe2b77a2272e77e2fb6738d78f4840d2f2f Mon Sep 17 00:00:00 2001 From: ellnix Date: Fri, 3 Jan 2025 13:31:05 +0100 Subject: [PATCH 3/4] Add code-samples for facet and prefix search --- .code-samples.meilisearch.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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: |- From 6a93a5ceca7bbce66f64e7a54359e9256b647ead Mon Sep 17 00:00:00 2001 From: ellnix Date: Fri, 3 Jan 2025 13:31:30 +0100 Subject: [PATCH 4/4] Re-generate rubocop config --- .rubocop_todo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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.