From b51da5f4bdeb82b27b8c1ee9939b75c8667a1f8d Mon Sep 17 00:00:00 2001 From: Nick Pezza Date: Wed, 28 Aug 2024 10:30:14 -0400 Subject: [PATCH] FIxes --- lib/redi_search/schema.rb | 4 +-- lib/redi_search/schema/vector_field.rb | 39 +++++++++++--------------- lib/redi_search/search/clauses.rb | 4 +-- 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/lib/redi_search/schema.rb b/lib/redi_search/schema.rb index 188202c..9c7b708 100644 --- a/lib/redi_search/schema.rb +++ b/lib/redi_search/schema.rb @@ -18,7 +18,7 @@ def numeric_field(name, ...) self[name] || push(Schema::NumericField.new(name, ...)) end - def vector_field(name, **options, &block) + def vector_field(name, ...) self[name] || push(Schema::VectorField.new(name, ...)) end @@ -30,7 +30,7 @@ def geo_field(name, ...) self[name] || push(Schema::GeoField.new(name, ...)) end - def add_field(name, type, ...) + def add_field(name, type, ...) # rubocop:disable Metrics/MethodLength case type when :text then method(:text_field) when :vector then method(:vector_field) diff --git a/lib/redi_search/schema/vector_field.rb b/lib/redi_search/schema/vector_field.rb index b0d7c29..c07b35f 100644 --- a/lib/redi_search/schema/vector_field.rb +++ b/lib/redi_search/schema/vector_field.rb @@ -3,24 +3,24 @@ module RediSearch class Schema class VectorField < Field - def initialize(name, - algorithm: "FLAT", - count: 0, - type: "FLOAT32", - dim: 0, - distance_metric: "COSINE", - initial_cap: 0, - block_size: 1024, - sortable: false, + def initialize(name, + algorithm: "FLAT", + count: 0, + type: "FLOAT32", + dim: 0, + distance_metric: "COSINE", + initial_cap: 0, + block_size: 1024, + sortable: false, no_index: false, &block) @name = name @value_block = block - { algorithm: algorithm, count: count, type: type, - dim: dim, distance_metric: distance_metric, initial_cap: initial_cap, - block_size: block_size, sortable: sortable, - no_index: no_index }.each do |attr, value| - instance_variable_set("@#{attr}", value) + { algorithm:, count:, type:, + dim:, distance_metric:, initial_cap:, + block_size:, sortable:, + no_index: }.each do |attr, value| + instance_variable_set(:"@#{attr}", value) end end @@ -39,15 +39,8 @@ def to_a private - attr_reader :algorithm, - :count, - :type, - :dim, - :distance_metric, - :initial_cap, - :block_size, - :sortable, - :no_index + attr_reader :algorithm, :count, :type, :dim, :distance_metric, + :initial_cap, :block_size, :sortable, :no_index def boolean_options %i(sortable no_index) diff --git a/lib/redi_search/search/clauses.rb b/lib/redi_search/search/clauses.rb index 74f261b..e671b4d 100644 --- a/lib/redi_search/search/clauses.rb +++ b/lib/redi_search/search/clauses.rb @@ -32,7 +32,7 @@ def return(*fields) end def params(*fields) - add_to_clauses(Params.new(fields: fields)) + add_to_clauses(Params.new(fields:)) end def highlight(fields: [], opening_tag: "", closing_tag: "") @@ -46,7 +46,7 @@ def slop(slop) end def dialect(dialect) - add_to_clauses(Dialect.new(dialect: dialect)) + add_to_clauses(Dialect.new(dialect:)) end def timeout(timeout)