schema

package
v1.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2023 License: BSD-3-Clause Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ErrorNoSuchClass    string = "no such class with name '%s' found in the schema. Check your schema files for which classes are available"
	ErrorNoSuchProperty string = "" /* 135-byte string literal not displayed */
	ErrorNoSuchDatatype string = "given value-DataType does not exist."
)
View Source
const (
	ClassNameRegexCore = `[A-Z][_0-9A-Za-z]*`
	ShardNameRegexCore = `[A-Za-z0-9\-\_]{1,64}`
)

Variables

View Source
var DeprecatedPrimitiveDataTypes []DataType = []DataType{

	DataTypeString, DataTypeStringArray,
}
View Source
var ErrRefToNonexistentClass = errors.New("reference property to nonexistent class")

Functions

func GetClassByName

func GetClassByName(s *models.Schema, className string) (*models.Class, error)

GetClassByName returns the class by its name

func GetPropertyByName

func GetPropertyByName(c *models.Class, propName string) (*models.Property, error)

GetPropertyByName returns the class by its name

func IsArrayDataType

func IsArrayDataType(dt []string) bool

func IsBlobDataType

func IsBlobDataType(dt []string) bool

func IsPropertyLength

func IsPropertyLength(propName string, offset int) (string, bool)

IsPropertyLength returns if a string is a filters for property length. They have the form len(*PROPNAME*)

func IsRefDataType

func IsRefDataType(dt []string) bool

func IsValidValueDataType

func IsValidValueDataType(dt string) bool

IsValidValueDataType checks whether the given string is a valid data type

func LowercaseAllPropertyNames added in v1.18.2

func LowercaseAllPropertyNames(props []*models.Property) []*models.Property

func LowercaseFirstLetter added in v1.18.2

func LowercaseFirstLetter(name string) string

func MultiTenancyEnabled added in v1.20.0

func MultiTenancyEnabled(class *models.Class) bool

func UppercaseClassName added in v1.18.2

func UppercaseClassName(name string) string

func ValidateReservedPropertyName

func ValidateReservedPropertyName(name string) error

ValidateReservedPropertyName validates that a string is not a reserved property name

Types

type BM25Config

type BM25Config struct {
	K1 float64
	B  float64
}

type ClassAndProperty

type ClassAndProperty struct {
	ClassName    ClassName
	PropertyName PropertyName
}

type ClassName

type ClassName string

Newtype to denote that this string is used as a Class name

func AssertValidClassName

func AssertValidClassName(name string) ClassName

AssertValidClassName assert that this string is a valid class name or panics and should therefore most likely not be used

func ValidateClassName

func ValidateClassName(name string) (ClassName, error)

ValidateClassName validates that this string is a valid class name (format wise)

func (ClassName) String

func (c ClassName) String() string

type DataType

type DataType string
const (
	// DataTypeCRef The data type is a cross-reference, it is starting with a capital letter
	DataTypeCRef DataType = "cref"
	// DataTypeText The data type is a value of type string
	DataTypeText DataType = "text"
	// DataTypeInt The data type is a value of type int
	DataTypeInt DataType = "int"
	// DataTypeNumber The data type is a value of type number/float
	DataTypeNumber DataType = "number"
	// DataTypeBoolean The data type is a value of type boolean
	DataTypeBoolean DataType = "boolean"
	// DataTypeDate The data type is a value of type date
	DataTypeDate DataType = "date"
	// DataTypeGeoCoordinates is used to represent geo coordintaes, i.e. latitude
	// and longitude pairs of locations on earth
	DataTypeGeoCoordinates DataType = "geoCoordinates"
	// DataTypePhoneNumber represents a parsed/to-be-parsed phone number
	DataTypePhoneNumber DataType = "phoneNumber"
	// DataTypeBlob represents a base64 encoded data
	DataTypeBlob DataType = "blob"
	// DataTypeTextArray The data type is a value of type string array
	DataTypeTextArray DataType = "text[]"
	// DataTypeIntArray The data type is a value of type int array
	DataTypeIntArray DataType = "int[]"
	// DataTypeNumberArray The data type is a value of type number/float array
	DataTypeNumberArray DataType = "number[]"
	// DataTypeBooleanArray The data type is a value of type boolean array
	DataTypeBooleanArray DataType = "boolean[]"
	// DataTypeDateArray The data type is a value of type date array
	DataTypeDateArray DataType = "date[]"
	// DataTypeUUID is a native UUID data type. It is stored in it's raw byte
	// representation and therefore takes up less space than storing a UUID as a
	// string
	DataTypeUUID DataType = "uuid"
	// DataTypeUUIDArray is the array version of DataTypeUUID
	DataTypeUUIDArray DataType = "uuid[]"

	// deprecated as of v1.19, replaced by DataTypeText + relevant tokenization setting
	// DataTypeString The data type is a value of type string
	DataTypeString DataType = "string"
	// deprecated as of v1.19, replaced by DataTypeTextArray + relevant tokenization setting
	// DataTypeArrayString The data type is a value of type string array
	DataTypeStringArray DataType = "string[]"
)

func AsPrimitive added in v1.19.0

func AsPrimitive(dataType []string) (DataType, bool)

func GetPropertyDataType

func GetPropertyDataType(class *models.Class, propertyName string) (*DataType, error)

GetPropertyDataType checks whether the given string is a valid data type

func GetValueDataTypeFromString

func GetValueDataTypeFromString(dt string) (*DataType, error)

GetValueDataTypeFromString checks whether the given string is a valid data type

func IsArrayType

func IsArrayType(dt DataType) (DataType, bool)

func (DataType) PropString added in v1.19.0

func (dt DataType) PropString() []string

func (DataType) String added in v1.19.0

func (dt DataType) String() string

type InvertedIndexConfig

type InvertedIndexConfig struct {
	BM25                BM25Config
	Stopwords           models.StopwordConfig
	IndexTimestamps     bool
	IndexNullState      bool
	IndexPropertyLength bool
}

type PropertyDataType

type PropertyDataType interface {
	Kind() PropertyKind
	IsPrimitive() bool
	AsPrimitive() DataType
	IsReference() bool
	Classes() []ClassName
	ContainsClass(name ClassName) bool
}

type PropertyKind

type PropertyKind int
const (
	PropertyKindPrimitive PropertyKind = 1
	PropertyKindRef       PropertyKind = 2
)

type PropertyName

type PropertyName string

Newtype to denote that this string is used as a Property name

func AssertValidPropertyName

func AssertValidPropertyName(name string) PropertyName

AssertValidPropertyName asserts that this string is a valid property name or panics and should therefore most likely never be used.

func ValidatePropertyName

func ValidatePropertyName(name string) (PropertyName, error)

ValidatePropertyName validates that this string is a valid property name

func (PropertyName) String

func (p PropertyName) String() string

type Schema

type Schema struct {
	Objects *models.Schema
}

Describes the schema that is used in Weaviate.

func Empty

func Empty() Schema

func (*Schema) FindClassByName

func (s *Schema) FindClassByName(className ClassName) *models.Class

FindClassByName will find either a Thing or Class by name.

func (*Schema) FindPropertyDataType

func (s *Schema) FindPropertyDataType(dataType []string) (PropertyDataType, error)

Based on the schema, return a valid description of the defined datatype

Note that this function will error if referenced classes do not exist. If you don't want such validation, use [Schema.FindPropertyDataTypeRelaxedRefs] instead and set relax to true

func (*Schema) FindPropertyDataTypeWithRefs

func (s *Schema) FindPropertyDataTypeWithRefs(
	dataType []string, relaxCrossRefValidation bool, beloningToClass ClassName,
) (PropertyDataType, error)

Based on the schema, return a valid description of the defined datatype If relaxCrossRefValidation is set, there is no check if the referenced class exists in the schema. This can be helpful in scenarios, such as restoring from a backup where we have no guarantee over the order of class creation. If belongingToClass is set and equal to referenced class, check whether class exists in the schema is skipped. This is done to allow creating class schema with properties referencing to itself. Previously such properties had to be created separately only after creation of class schema

func (*Schema) GetClass

func (s *Schema) GetClass(className ClassName) *models.Class

func (*Schema) GetProperty

func (s *Schema) GetProperty(className ClassName, propName PropertyName) (*models.Property, error)

func (*Schema) GetPropsOfType

func (s *Schema) GetPropsOfType(propType string) []ClassAndProperty

func (*Schema) SemanticSchemaFor

func (s *Schema) SemanticSchemaFor() *models.Schema

Return one of the semantic schema's

type VectorIndexConfig

type VectorIndexConfig interface {
	IndexType() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL