Module: Sequel::Plugins::Pgvector::InstanceMethods
- Defined in:
- lib/sequel/plugins/pgvector.rb
Instance Method Summary collapse
Instance Method Details
#[](k) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/sequel/plugins/pgvector.rb', line 72 def [](k) if self.class.vector_columns.key?(k.to_sym) ::Pgvector.decode(super) else super end end |
#[]=(k, v) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/sequel/plugins/pgvector.rb', line 64 def []=(k, v) if self.class.vector_columns.key?(k.to_sym) && !v.is_a?(String) super(k, ::Pgvector.encode(v)) else super end end |
#nearest_neighbors(column, **options) ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'lib/sequel/plugins/pgvector.rb', line 54 def nearest_neighbors(column, **) column = column.to_sym # important! check if neighbor attribute before calling send raise ArgumentError, "Invalid column" unless self.class.vector_columns[column] self.class .nearest_neighbors(column, self[column], **) .exclude(primary_key => self[primary_key]) end |