github.com/weaviate/weaviate@v1.24.6/entities/vectorindex/config.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 package vectorindex 13 14 import ( 15 "fmt" 16 17 "github.com/weaviate/weaviate/entities/schema" 18 "github.com/weaviate/weaviate/entities/vectorindex/flat" 19 "github.com/weaviate/weaviate/entities/vectorindex/hnsw" 20 ) 21 22 const ( 23 DefaultVectorIndexType = VectorIndexTypeHNSW 24 VectorIndexTypeHNSW = "hnsw" 25 VectorIndexTypeFLAT = "flat" 26 ) 27 28 // ParseAndValidateConfig from an unknown input value, as this is not further 29 // specified in the API to allow of exchanging the index type 30 func ParseAndValidateConfig(input interface{}, vectorIndexType string) (schema.VectorIndexConfig, error) { 31 if len(vectorIndexType) == 0 { 32 vectorIndexType = DefaultVectorIndexType 33 } 34 35 switch vectorIndexType { 36 case VectorIndexTypeHNSW: 37 return hnsw.ParseAndValidateConfig(input) 38 case VectorIndexTypeFLAT: 39 return flat.ParseAndValidateConfig(input) 40 default: 41 return nil, fmt.Errorf("Invalid vectorIndexType (%s). Supported types are hnsw and flat", vectorIndexType) 42 } 43 }