WeaviateEx.Data.ReferenceToMulti (WeaviateEx v0.7.4)

View Source

Multi-target reference specification.

Use this when you have a reference property that can point to multiple different collections (multi-target reference).

Examples

# Single target in a multi-target property
ref = ReferenceToMulti.new("Category", "cat-uuid")

# Multiple targets
ref = ReferenceToMulti.new("Category", ["uuid1", "uuid2"])

# Use with References API
References.add(client, "Article", source_uuid, "relatedTo",
  ReferenceToMulti.to_map(ref))

Summary

Functions

Create a new multi-target reference.

Convert to beacon format for API requests.

Convert to map format for use with References API.

Types

t()

@type t() :: %WeaviateEx.Data.ReferenceToMulti{
  target_collection: String.t(),
  uuids: String.t() | [String.t()]
}

Functions

new(target_collection, uuids)

@spec new(String.t(), String.t() | [String.t()]) :: t()

Create a new multi-target reference.

Parameters

  • target_collection - The target collection name
  • uuids - Single UUID or list of UUIDs

Examples

ReferenceToMulti.new("Category", "cat-uuid")
ReferenceToMulti.new("Category", ["uuid1", "uuid2"])

to_beacons(reference_to_multi)

@spec to_beacons(t()) :: [map()]

Convert to beacon format for API requests.

Returns a list of beacon maps suitable for the Weaviate API.

Examples

ref = ReferenceToMulti.new("Category", "cat-uuid")
ReferenceToMulti.to_beacons(ref)
# => [%{"beacon" => "weaviate://localhost/Category/cat-uuid"}]

to_map(ref)

@spec to_map(t()) :: map()

Convert to map format for use with References API.

Examples

ref = ReferenceToMulti.new("Category", "cat-uuid")
ReferenceToMulti.to_map(ref)
# => %{target_collection: "Category", uuids: "cat-uuid"}