github.com/weaviate/weaviate@v1.24.6/entities/modulecapabilities/additional.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 modulecapabilities 13 14 import ( 15 "context" 16 17 "github.com/tailor-inc/graphql" 18 "github.com/tailor-inc/graphql/language/ast" 19 "github.com/weaviate/weaviate/entities/moduletools" 20 "github.com/weaviate/weaviate/entities/search" 21 ) 22 23 // GraphQLFieldFn generates graphql field based on classname 24 type GraphQLFieldFn = func(classname string) *graphql.Field 25 26 // ExtractAdditionalFn extracts parameters from graphql queries 27 type ExtractAdditionalFn = func(param []*ast.Argument) interface{} 28 29 // AdditionalPropertyWithSearchVector defines additional property params 30 // with the ability to pass search vector 31 type AdditionalPropertyWithSearchVector interface { 32 SetSearchVector(vector []float32) 33 } 34 35 // AdditionalPropertyFn defines interface for additional property 36 // functions performing given logic 37 type AdditionalPropertyFn = func(ctx context.Context, 38 in []search.Result, params interface{}, limit *int, 39 argumentModuleParams map[string]interface{}, cfg moduletools.ClassConfig) ([]search.Result, error) 40 41 // AdditionalSearch defines on which type of query a given 42 // additional logic can be performed 43 type AdditionalSearch struct { 44 ObjectGet AdditionalPropertyFn 45 ObjectList AdditionalPropertyFn 46 ExploreGet AdditionalPropertyFn 47 ExploreList AdditionalPropertyFn 48 } 49 50 // AdditionalProperty defines all the needed settings / methods 51 // to be set in order to add the additional property to Weaviate 52 type AdditionalProperty struct { 53 RestNames []string 54 DefaultValue interface{} 55 GraphQLNames []string 56 GraphQLFieldFunction GraphQLFieldFn 57 GraphQLExtractFunction ExtractAdditionalFn 58 SearchFunctions AdditionalSearch 59 } 60 61 // AdditionalProperties groups whole interface methods needed 62 // for adding the capability of additional properties 63 type AdditionalProperties interface { 64 AdditionalProperties() map[string]AdditionalProperty 65 }