123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Extensions::Vector

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/mongoid/extensions/vector.rb

Overview

Adds type-casting behavior to ::BSON::Vector class so that a field declared with type: BSON::Vector is stored as a ::BSON binary of the vector subtype and read back as a ::BSON::Vector.

Querying by an exact vector value (e.g. where(embedding: vector)) is not supported: ::BSON::Vector subclasses Array, so the criteria selector treats it as a list of elements rather than a scalar. Use Atlas Vector Search ($vectorSearch) for similarity queries on vector fields.

Instance Method Summary

Instance Method Details

#mongoizeBSON::Binary | nil

Turn the object from the ruby type we deal with to a Mongo friendly type.

Examples:

Mongoize the object.

object.mongoize

Returns:

[ GitHub ]

  
# File 'lib/mongoid/extensions/vector.rb', line 21

def mongoize
  BSON::Vector.mongoize(self)
end