WeaviateEx.Types.DataType (WeaviateEx v0.7.4)

View Source

Weaviate data types for property definitions.

Provides type-safe conversion between Elixir atoms and Weaviate data type strings.

Supported Types

  • :text / :text_array - Text values
  • :int / :int_array - Integer values
  • :boolean / :boolean_array - Boolean values
  • :number / :number_array - Floating point values
  • :date / :date_array - Date/time values (RFC3339)
  • :uuid / :uuid_array - UUID values
  • :geo_coordinates - Geographic coordinates (lat/lon)
  • :blob - Base64-encoded binary data
  • :phone_number - Phone numbers with parsing
  • :object / :object_array - Nested objects

Examples

iex> DataType.to_string(:text)
"text"

iex> DataType.from_string("geoCoordinates")
{:ok, :geo_coordinates}

iex> DataType.valid?(:text)
true

Summary

Functions

List all supported data types.

Check if a data type is an array type.

Convert Weaviate data type string to atom.

Convert atom to Weaviate data type string.

Check if a data type atom is valid.

Types

t()

@type t() ::
  :text
  | :text_array
  | :int
  | :int_array
  | :boolean
  | :boolean_array
  | :number
  | :number_array
  | :date
  | :date_array
  | :uuid
  | :uuid_array
  | :geo_coordinates
  | :blob
  | :phone_number
  | :object
  | :object_array

Functions

all()

@spec all() :: [t()]

List all supported data types.

Examples

iex> :text in DataType.all()
true

array?(type)

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

Check if a data type is an array type.

Examples

iex> DataType.array?(:text_array)
true

iex> DataType.array?(:text)
false

from_string(str)

@spec from_string(String.t()) ::
  {:ok, t()} | {:error, {:unknown_data_type, String.t()}}

Convert Weaviate data type string to atom.

Examples

iex> DataType.from_string("text")
{:ok, :text}

iex> DataType.from_string("unknown")
{:error, {:unknown_data_type, "unknown"}}

to_string(type)

@spec to_string(t()) :: String.t()

Convert atom to Weaviate data type string.

Examples

iex> DataType.to_string(:text)
"text"

iex> DataType.to_string(:geo_coordinates)
"geoCoordinates"

valid?(type)

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

Check if a data type atom is valid.

Examples

iex> DataType.valid?(:text)
true

iex> DataType.valid?(:invalid)
false