Class: Redis::Commands::Search::VectorFieldDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/redis/commands/modules/search/schema.rb

Overview

The block DSL used by SchemaDefinition#vector_field to declare the attributes of a VectorField.

Instance Method Summary collapse

Constructor Details

#initialize(field) ⇒ VectorFieldDefinition

Returns a new instance of VectorFieldDefinition.



185
186
187
# File 'lib/redis/commands/modules/search/schema.rb', line 185

def initialize(field)
  @field = field
end

Instance Method Details

#dim(value) ⇒ Object

Set the vector dimensionality attribute.

Parameters:

  • value (Object) —

    the DIM attribute value

Returns:

  • (Object) —

    the stored value



201
202
203
# File 'lib/redis/commands/modules/search/schema.rb', line 201

def dim(value)
  @field.add_attribute(:dim, value)
end

#distance_metric(value) ⇒ Object

Set the distance metric attribute (e.g. L2, COSINE).

Parameters:

  • value (Object) —

    the DISTANCE_METRIC attribute value

Returns:

  • (Object) —

    the stored value



209
210
211
# File 'lib/redis/commands/modules/search/schema.rb', line 209

def distance_metric(value)
  @field.add_attribute(:distance_metric, value)
end

#type(value) ⇒ Object

Set the vector element type attribute (e.g. FLOAT32).

Parameters:

  • value (Object) —

    the TYPE attribute value

Returns:

  • (Object) —

    the stored value



193
194
195
# File 'lib/redis/commands/modules/search/schema.rb', line 193

def type(value)
  @field.add_attribute(:type, value)
end