Skip to content

Commit

Permalink
FIxes
Browse files Browse the repository at this point in the history
  • Loading branch information
npezza93 committed Aug 28, 2024
1 parent f1c6645 commit b51da5f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/redi_search/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
39 changes: 16 additions & 23 deletions lib/redi_search/schema/vector_field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/redi_search/search/clauses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: "<b>", closing_tag: "</b>")
Expand All @@ -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)
Expand Down

0 comments on commit b51da5f

Please sign in to comment.