github.com/weaviate/weaviate@v1.24.6/entities/models/property.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 // Code generated by go-swagger; DO NOT EDIT. 13 14 package models 15 16 // This file was generated by the swagger tool. 17 // Editing this file might prove futile when you re-run the swagger generate command 18 19 import ( 20 "context" 21 "encoding/json" 22 "strconv" 23 24 "github.com/go-openapi/errors" 25 "github.com/go-openapi/strfmt" 26 "github.com/go-openapi/swag" 27 "github.com/go-openapi/validate" 28 ) 29 30 // Property property 31 // 32 // swagger:model Property 33 type Property struct { 34 35 // Can be a reference to another type when it starts with a capital (for example Person), otherwise "string" or "int". 36 DataType []string `json:"dataType"` 37 38 // Description of the property. 39 Description string `json:"description,omitempty"` 40 41 // Optional. Should this property be indexed in the inverted index. Defaults to true. If you choose false, you will not be able to use this property in where filters. This property has no affect on vectorization decisions done by modules 42 IndexFilterable *bool `json:"indexFilterable,omitempty"` 43 44 // Optional. Should this property be indexed in the inverted index. Defaults to true. If you choose false, you will not be able to use this property in where filters, bm25 or hybrid search. This property has no affect on vectorization decisions done by modules (deprecated as of v1.19; use indexFilterable or/and indexSearchable instead) 45 IndexInverted *bool `json:"indexInverted,omitempty"` 46 47 // Optional. Should this property be indexed in the inverted index. Defaults to true. Applicable only to properties of data type text and text[]. If you choose false, you will not be able to use this property in bm25 or hybrid search. This property has no affect on vectorization decisions done by modules 48 IndexSearchable *bool `json:"indexSearchable,omitempty"` 49 50 // Configuration specific to modules this Weaviate instance has installed 51 ModuleConfig interface{} `json:"moduleConfig,omitempty"` 52 53 // Name of the property as URI relative to the schema URL. 54 Name string `json:"name,omitempty"` 55 56 // The properties of the nested object(s). Applies to object and object[] data types. 57 NestedProperties []*NestedProperty `json:"nestedProperties,omitempty"` 58 59 // Determines tokenization of the property as separate words or whole field. Optional. Applies to text and text[] data types. Allowed values are `word` (default; splits on any non-alphanumerical, lowercases), `lowercase` (splits on white spaces, lowercases), `whitespace` (splits on white spaces), `field` (trims). Not supported for remaining data types 60 // Enum: [word lowercase whitespace field trigram gse] 61 Tokenization string `json:"tokenization,omitempty"` 62 } 63 64 // Validate validates this property 65 func (m *Property) Validate(formats strfmt.Registry) error { 66 var res []error 67 68 if err := m.validateNestedProperties(formats); err != nil { 69 res = append(res, err) 70 } 71 72 if err := m.validateTokenization(formats); err != nil { 73 res = append(res, err) 74 } 75 76 if len(res) > 0 { 77 return errors.CompositeValidationError(res...) 78 } 79 return nil 80 } 81 82 func (m *Property) validateNestedProperties(formats strfmt.Registry) error { 83 if swag.IsZero(m.NestedProperties) { // not required 84 return nil 85 } 86 87 for i := 0; i < len(m.NestedProperties); i++ { 88 if swag.IsZero(m.NestedProperties[i]) { // not required 89 continue 90 } 91 92 if m.NestedProperties[i] != nil { 93 if err := m.NestedProperties[i].Validate(formats); err != nil { 94 if ve, ok := err.(*errors.Validation); ok { 95 return ve.ValidateName("nestedProperties" + "." + strconv.Itoa(i)) 96 } else if ce, ok := err.(*errors.CompositeError); ok { 97 return ce.ValidateName("nestedProperties" + "." + strconv.Itoa(i)) 98 } 99 return err 100 } 101 } 102 103 } 104 105 return nil 106 } 107 108 var propertyTypeTokenizationPropEnum []interface{} 109 110 func init() { 111 var res []string 112 if err := json.Unmarshal([]byte(`["word","lowercase","whitespace","field","trigram","gse"]`), &res); err != nil { 113 panic(err) 114 } 115 for _, v := range res { 116 propertyTypeTokenizationPropEnum = append(propertyTypeTokenizationPropEnum, v) 117 } 118 } 119 120 const ( 121 122 // PropertyTokenizationWord captures enum value "word" 123 PropertyTokenizationWord string = "word" 124 125 // PropertyTokenizationLowercase captures enum value "lowercase" 126 PropertyTokenizationLowercase string = "lowercase" 127 128 // PropertyTokenizationWhitespace captures enum value "whitespace" 129 PropertyTokenizationWhitespace string = "whitespace" 130 131 // PropertyTokenizationField captures enum value "field" 132 PropertyTokenizationField string = "field" 133 134 // PropertyTokenizationTrigram captures enum value "trigram" 135 PropertyTokenizationTrigram string = "trigram" 136 137 // PropertyTokenizationGse captures enum value "gse" 138 PropertyTokenizationGse string = "gse" 139 ) 140 141 // prop value enum 142 func (m *Property) validateTokenizationEnum(path, location string, value string) error { 143 if err := validate.EnumCase(path, location, value, propertyTypeTokenizationPropEnum, true); err != nil { 144 return err 145 } 146 return nil 147 } 148 149 func (m *Property) validateTokenization(formats strfmt.Registry) error { 150 if swag.IsZero(m.Tokenization) { // not required 151 return nil 152 } 153 154 // value enum 155 if err := m.validateTokenizationEnum("tokenization", "body", m.Tokenization); err != nil { 156 return err 157 } 158 159 return nil 160 } 161 162 // ContextValidate validate this property based on the context it is used 163 func (m *Property) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 164 var res []error 165 166 if err := m.contextValidateNestedProperties(ctx, formats); err != nil { 167 res = append(res, err) 168 } 169 170 if len(res) > 0 { 171 return errors.CompositeValidationError(res...) 172 } 173 return nil 174 } 175 176 func (m *Property) contextValidateNestedProperties(ctx context.Context, formats strfmt.Registry) error { 177 178 for i := 0; i < len(m.NestedProperties); i++ { 179 180 if m.NestedProperties[i] != nil { 181 if err := m.NestedProperties[i].ContextValidate(ctx, formats); err != nil { 182 if ve, ok := err.(*errors.Validation); ok { 183 return ve.ValidateName("nestedProperties" + "." + strconv.Itoa(i)) 184 } else if ce, ok := err.(*errors.CompositeError); ok { 185 return ce.ValidateName("nestedProperties" + "." + strconv.Itoa(i)) 186 } 187 return err 188 } 189 } 190 191 } 192 193 return nil 194 } 195 196 // MarshalBinary interface implementation 197 func (m *Property) MarshalBinary() ([]byte, error) { 198 if m == nil { 199 return nil, nil 200 } 201 return swag.WriteJSON(m) 202 } 203 204 // UnmarshalBinary interface implementation 205 func (m *Property) UnmarshalBinary(b []byte) error { 206 var res Property 207 if err := swag.ReadJSON(b, &res); err != nil { 208 return err 209 } 210 *m = res 211 return nil 212 }