Skip to main content

MetadataSchemaError Objects

Raised when an invariant is violated when mutating metadata schemas

MetadataSchema Objects

A class to manage the metadata schema for an organization. Methods: save() -> None: Saves the metadata schema to the backend if it has been modified.

save

Saves the metadata schema to the backend if changes have been made.

add_embedding

Adds a new embedding to the metadata schema. Arguments: k : str: The key under which the embedding will be stored in the schema. size : int: The size of the embedding. Raises:
  • MetadataSchemaError - If the key k is already defined in the schema.

add_geospatial

Adds a new geospatial type to the metadata schema. Arguments: k : str: The key under which the geospatial coordinates will be stored in the schema. Raises:
  • MetadataSchemaError - If the key k is already defined in the schema.

add_enum

Adds a new enum to the metadata schema. Arguments: k : str: The key under which the enum will be stored in the schema. values : Sequence[str]: The set of values for the enum (min 1, max 256). Raises:
  • MetadataSchemaError - If the key k is already defined in the schema.

add_enum_options

Adds extra valid enum values to an existing enum schema. Arguments: k : str: The key referencing the enum. values : Sequence[str]: The set of new values to add to the enum (min 1, max 256). Raises:
  • MetadataSchemaError - If the key k is not defined in the schema or is not an enum.

add_scalar

Sets a simple metadata type for a given key in the schema. Arguments: k : str: The key for which the metadata type is being set. data_type : Literal[“boolean”, “datetime”, “number”, “uuid”, “varchar”, “text”, “string”, “long_string”] The type of metadata to be associated with the key. Must be a valid identifier. “string” is an alias of “varchar” “long_string” is an alias of “text” Raises:
  • MetadataSchemaError - If the key k is already defined in the schema with a conflicting type.
  • ValueError - If data_type is not a valid type of metadata identifier.

set_scalar

Sets a simple metadata type for a given key in the schema. Alias of add_scalar Arguments: k : str: The key for which the metadata type is being set. data_type : Literal[“boolean”, “datetime”, “number”, “uuid”, “varchar”, “text”, “string”, “long_string”] The type of metadata to be associated with the key. Must be a valid identifier. “string” is an alias of “varchar” “long_string” is an alias of “text” Raises:
  • MetadataSchemaError - If the key k is already defined in the schema with a conflicting type.
  • ValueError - If data_type is not a valid type of metadata identifier.

delete_key

Delete a metadata key from the schema. Arguments: k : str: The key for which the metadata type is being deleted.
  • hard - bool: If the deletion should prevent indexing of this key unconditionally. Setting this to true prevents restoring the type definition in the future.
Raises:
  • MetadataSchemaError - If the key k is already deleted or not present in the schema

restore_key

Restore a deleted metadata key to its original value. Arguments: k : str: The key for which the metadata type is to be restored. Raises:
  • MetadataSchemaError - If the key k is not already deleted or not present in the schema

keys

Returns a sequence of all keys defined in the metadata schema. Returns:
  • Sequence[str] - A list of keys present in the metadata schema.

has_key

Check if any definition exists for a key. Arguments: k : str: The key for which the metadata type is to be retrieved.

is_key_deleted

Check if the key is defined as deleted. (Tombstone type) Arguments: k : str: The key for which the metadata type is to be retrieved.

get_key_type

Retrieves the metadata type associated with a given key. Arguments: k : str: The key for which the metadata type is to be retrieved. Returns: Literal[“boolean”, “datetime”, “uuid”, “number”, “varchar”, “text”, “embedding”, “enum”, “geospatial”]: The metadata type associated with the key k. Raises:
  • MetadataSchemaError - If the key k is not supported by the current SDK.

get_embedding_size

Retrieves size associated with a given embedding. Arguments: k : str: The key for which the metadata type is to be retrieved. Returns:
  • int - The size of the embedding
Raises:
  • MetadataSchemaError - If the key k is not defined in the schema or is not an embedding

get_enum_options

Retrieves all values associated with a given enum. Arguments: k : str: The key for which the metadata type is to be retrieved. Returns:
  • Sequence[str] - The list of all values associated with an enum type.
Raises:
  • MetadataSchemaError - If the key k is not defined in the schema or is not an enum.