github.com/weaviate/weaviate@v1.24.6/test/acceptance/graphql_resolvers/local_get_with_expected_failures.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 test 13 14 import ( 15 "testing" 16 17 graphqlhelper "github.com/weaviate/weaviate/test/helper/graphql" 18 19 "github.com/stretchr/testify/assert" 20 "github.com/weaviate/weaviate/entities/models" 21 "github.com/weaviate/weaviate/entities/schema" 22 "github.com/weaviate/weaviate/test/helper" 23 ) 24 25 func getsWithExpectedFailures(t *testing.T) { 26 t.Run("get with certainty on l2-squared distancer", func(t *testing.T) { 27 className := "L2DistanceClass" 28 defer deleteObjectClass(t, className) 29 30 t.Run("create class configured with distance type l2-squared", func(t *testing.T) { 31 createObjectClass(t, &models.Class{ 32 Class: className, 33 ModuleConfig: map[string]interface{}{ 34 "text2vec-contextionary": map[string]interface{}{ 35 "vectorizeClassName": true, 36 }, 37 }, 38 VectorIndexConfig: map[string]interface{}{ 39 "distance": "l2-squared", 40 }, 41 Properties: []*models.Property{ 42 { 43 Name: "name", 44 DataType: schema.DataTypeText.PropString(), 45 Tokenization: models.PropertyTokenizationWhitespace, 46 }, 47 }, 48 }) 49 }) 50 51 t.Run("assert failure to get", func(t *testing.T) { 52 query := ` 53 { 54 Get { 55 L2DistanceClass(nearVector: {vector:[1,1,1], certainty: 0.8}) { 56 name 57 } 58 } 59 }` 60 61 result := graphqlhelper.ErrorGraphQL(t, helper.RootAuth, query) 62 assert.Len(t, result, 1) 63 64 errMsg := result[0].Message 65 assert.Equal(t, "can't compute and return certainty when vector index is configured with l2-squared distance", errMsg) 66 }) 67 }) 68 69 t.Run("get with certainty on dot distancer", func(t *testing.T) { 70 className := "DotDistanceClass" 71 defer deleteObjectClass(t, className) 72 73 t.Run("create class configured with distance type dot", func(t *testing.T) { 74 createObjectClass(t, &models.Class{ 75 Class: className, 76 ModuleConfig: map[string]interface{}{ 77 "text2vec-contextionary": map[string]interface{}{ 78 "vectorizeClassName": true, 79 }, 80 }, 81 VectorIndexConfig: map[string]interface{}{ 82 "distance": "dot", 83 }, 84 Properties: []*models.Property{ 85 { 86 Name: "name", 87 DataType: schema.DataTypeText.PropString(), 88 Tokenization: models.PropertyTokenizationWhitespace, 89 }, 90 }, 91 }) 92 }) 93 94 t.Run("assert failure to get", func(t *testing.T) { 95 query := ` 96 { 97 Get { 98 DotDistanceClass(nearVector: {vector:[1,1,1], certainty: 0.8}) { 99 name 100 } 101 } 102 }` 103 104 result := graphqlhelper.ErrorGraphQL(t, helper.RootAuth, query) 105 assert.Len(t, result, 1) 106 107 errMsg := result[0].Message 108 assert.Equal(t, "can't compute and return certainty when vector index is configured with dot distance", errMsg) 109 }) 110 }) 111 }