WeaviateEx.Types.Reference (WeaviateEx v0.7.4)
View SourceCross-reference handling with multi-target vector support.
Represents a reference to another object in Weaviate, supporting both simple references and multi-target references for named vectors.
Simple Reference
ref = Reference.to("Author", "uuid-123")
# => %Reference{beacon: "weaviate://localhost/Author/uuid-123"}Multi-Target Reference
When using named vectors, you can specify which target vectors to use:
ref = Reference.multi_target("Author", "uuid-123", ["title_vector", "content_vector"])
# => %Reference{beacon: "...", target_vectors: ["title_vector", "content_vector"]}
Summary
Functions
Extracts the collection name from the reference beacon.
Extracts the object ID from the reference beacon.
Creates a reference from a beacon URL string.
Creates a Reference from a map (e.g., from API response).
Creates a multi-target reference specifying which named vectors to use.
Creates a reference to an object.
Converts the reference to a map for the Weaviate API.
Types
Functions
Extracts the collection name from the reference beacon.
Examples
ref = Reference.to("Author", "uuid-123")
Reference.extract_collection(ref)
# => {:ok, "Author"}
Extracts the object ID from the reference beacon.
Examples
ref = Reference.to("Author", "uuid-123")
Reference.extract_id(ref)
# => {:ok, "uuid-123"}
Creates a reference from a beacon URL string.
Automatically extracts and populates the target collection from the beacon.
Examples
Reference.from_beacon("weaviate://localhost/Author/uuid-123")
# => %Reference{beacon: "weaviate://localhost/Author/uuid-123", target_collection: "Author"}
Reference.from_beacon("weaviate://localhost/uuid-123")
# => %Reference{beacon: "weaviate://localhost/uuid-123", target_collection: nil}
Creates a Reference from a map (e.g., from API response).
Automatically extracts the target collection from the beacon.
Examples
Reference.from_map(%{"beacon" => "weaviate://localhost/Author/uuid-123"})
# => %Reference{beacon: "...", target_collection: "Author", target_vectors: []}
Reference.from_map(%{"beacon" => "weaviate://localhost/uuid-123"})
# => %Reference{beacon: "...", target_collection: nil, target_vectors: []}
Creates a multi-target reference specifying which named vectors to use.
Use this when you need to specify target vectors for ref2vec-centroid or other multi-vector scenarios.
Examples
Reference.multi_target("Author", "uuid-123", ["title_vector", "content_vector"])
Creates a reference to an object.
Options
:target_vectors- List of named vectors to use (for multi-target references)
Examples
Reference.to("Author", "uuid-123")
# => %Reference{beacon: "weaviate://localhost/Author/uuid-123"}
Reference.to("Author", "uuid-123", target_vectors: ["title_vector"])
# => %Reference{beacon: "...", target_vectors: ["title_vector"]}
Converts the reference to a map for the Weaviate API.
Examples
ref = Reference.to("Author", "uuid-123")
Reference.to_map(ref)
# => %{"beacon" => "weaviate://localhost/Author/uuid-123"}
ref = Reference.multi_target("Author", "uuid-123", ["title_vector"])
Reference.to_map(ref)
# => %{"beacon" => "...", "targetVectors" => ["title_vector"]}