AshNeo4j.Types.Vector (AshNeo4j v0.9.0)

Copy Markdown View Source

Ash attribute type for vector embeddings, stored as a Neo4j LIST<FLOAT>.

The Elixir-side value is a plain [float()] list, and it is persisted as a LIST<FLOAT> node property — which is what Neo4j's vector indexes and vector.similarity.cosine/2 operate on. The native Bolt 6.0 %Bolty.Types.Vector{} type is a query-parameter wire type and cannot be written as a node property, so it is never used for storage. cast_input/2 and cast_stored/2 still accept a %Bolty.Types.Vector{} defensively and unwrap it to [float()].

Cypher 25 required

Vector operations require Cypher 25 (Neo4j ≥ 2025.06) — not Bolt 6.0. With list storage and list query params, similarity search works over Bolt 5.8. This is an AshNeo4j-level requirement — see AshNeo4j.Cypher.require_cypher25!/0.

Constraints

  • :element_type:float32 (default) or :float64
  • :dimensions — expected number of dimensions; validated on cast when set

Usage

attribute :embedding, AshNeo4j.Types.Vector,
  constraints: [element_type: :float32, dimensions: 1536]

See AshNeo4j.Vector for index creation helpers and AshNeo4j.Functions.VectorSimilarity for cosine similarity filtering/sorting.

Summary

Functions

handle_change?()

prepare_change?()