WeaviateEx.Property.Nested (WeaviateEx v0.7.4)

View Source

Nested property definition for object and object_array data types.

Provides a typed struct for defining nested properties within object-type properties. Supports recursive nesting for complex data structures.

Examples

# Simple nested property
Nested.new(name: "author", data_type: :text)

# Nested object with sub-properties
Nested.new(
  name: "metadata",
  data_type: :object,
  nested_properties: [
    Nested.new(name: "author", data_type: :text),
    Nested.new(name: "tags", data_type: :text_array)
  ]
)

# Deeply nested structure
Nested.new(
  name: "metadata",
  data_type: :object,
  nested_properties: [
    Nested.new(
      name: "stats",
      data_type: :object,
      nested_properties: [
        Nested.new(name: "views", data_type: :int),
        Nested.new(name: "likes", data_type: :int)
      ]
    )
  ]
)

Summary

Functions

Parses a Weaviate API response into a Nested struct.

Creates a new nested property definition.

Checks if the nested property is an object type.

Converts a Nested struct to Weaviate API format.

Validates a Nested struct.

Types

t()

@type t() :: %WeaviateEx.Property.Nested{
  data_type: WeaviateEx.Types.DataType.t(),
  description: String.t() | nil,
  indexable: boolean() | nil,
  name: String.t(),
  nested_properties: [t()] | nil,
  tokenization: atom() | nil
}

Functions

from_api(api)

@spec from_api(map()) :: t()

Parses a Weaviate API response into a Nested struct.

Examples

api = %{"name" => "title", "dataType" => ["text"]}
Nested.from_api(api)
# => %Nested{name: "title", data_type: :text}

new(opts)

@spec new(keyword()) :: t()

Creates a new nested property definition.

Required Options

  • :name - Property name (required)
  • :data_type - Data type atom (required)

Optional Options

  • :nested_properties - List of child Nested structs (for object types)
  • :description - Property description
  • :indexable - Whether property is filterable/searchable
  • :tokenization - Tokenization strategy (:word, :whitespace, :field, etc.)

Examples

Nested.new(name: "title", data_type: :text)
Nested.new(name: "metadata", data_type: :object, nested_properties: [...])

object_type?(nested)

@spec object_type?(t()) :: boolean()

Checks if the nested property is an object type.

Examples

Nested.object_type?(%Nested{data_type: :object})
# => true

Nested.object_type?(%Nested{data_type: :text})
# => false

to_api(nested)

@spec to_api(t()) :: map()

Converts a Nested struct to Weaviate API format.

Examples

nested = Nested.new(name: "title", data_type: :text)
Nested.to_api(nested)
# => %{"name" => "title", "dataType" => ["text"]}

valid?(nested)

@spec valid?(t()) :: boolean()

Validates a Nested struct.

Returns true if:

  • Object types have nested_properties defined
  • Non-object types do NOT have nested_properties

Examples

nested = Nested.new(name: "title", data_type: :text)
Nested.valid?(nested)
# => true

nested = Nested.new(name: "data", data_type: :object)
Nested.valid?(nested)
# => false (object must have nested_properties)