github.com/weaviate/weaviate@v1.24.6/adapters/repos/db/propertyspecific/index.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 propertyspecific 13 14 import ( 15 "context" 16 17 "github.com/pkg/errors" 18 "github.com/weaviate/weaviate/adapters/repos/db/vector/geo" 19 "github.com/weaviate/weaviate/entities/schema" 20 ) 21 22 // Index - for now - only supports a Geo index as a property-specific index. 23 // This could be extended in the future, for example to allow vectorization of 24 // single properties, as opposed to only allowing vectorization of the entire 25 // object. 26 type Index struct { 27 Name string 28 Type schema.DataType 29 GeoIndex *geo.Index 30 } 31 32 // Indices is a collection of property-specific Indices by propname 33 type Indices map[string]Index 34 35 // ByProp retrieves a property-specific index by prop name. Second argument is 36 // false, if the index doesn't exist. 37 func (i Indices) ByProp(propName string) (Index, bool) { 38 index, ok := i[propName] 39 return index, ok 40 } 41 42 func (i Indices) DropAll(ctx context.Context) error { 43 for propName, index := range i { 44 if index.Type != schema.DataTypeGeoCoordinates { 45 return errors.Errorf("no implementation to delete property %s index of type %v", 46 propName, index.Type) 47 } 48 49 if err := index.GeoIndex.Drop(ctx); err != nil { 50 return errors.Wrapf(err, "drop property %s", propName) 51 } 52 53 index.GeoIndex = nil 54 delete(i, propName) 55 56 } 57 return nil 58 }