github.com/weaviate/weaviate@v1.24.6/test/acceptance/objects/skip_vector_index_test.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  	"github.com/go-openapi/strfmt"
    18  	"github.com/stretchr/testify/assert"
    19  	"github.com/stretchr/testify/require"
    20  	"github.com/weaviate/weaviate/client/objects"
    21  	"github.com/weaviate/weaviate/entities/models"
    22  	"github.com/weaviate/weaviate/test/helper"
    23  )
    24  
    25  func TestSkipVectorIndex(t *testing.T) {
    26  	// Import a class with vectorizer 'none' and 'skipVectorIndex: true', import
    27  	// objects without vectors.
    28  
    29  	t.Run("create schema", func(t *testing.T) {
    30  		createObjectClass(t, &models.Class{
    31  			Class: "TestSkipVectorIndex",
    32  			VectorIndexConfig: map[string]interface{}{
    33  				"skip": true,
    34  			},
    35  			Vectorizer: "none",
    36  			Properties: []*models.Property{
    37  				{
    38  					Name:     "name",
    39  					DataType: []string{"text"},
    40  				},
    41  			},
    42  		})
    43  	})
    44  
    45  	id := strfmt.UUID("d1d58565-3c9b-4ca6-ac7f-43f739700a1d")
    46  
    47  	t.Run("create object", func(t *testing.T) {
    48  		params := objects.NewObjectsCreateParams().WithBody(
    49  			&models.Object{
    50  				ID:         id,
    51  				Class:      "TestSkipVectorIndex",
    52  				Properties: map[string]interface{}{"name": "Jane Doe"},
    53  			})
    54  		_, err := helper.Client(t).Objects.ObjectsCreate(params, nil)
    55  		require.Nil(t, err, "creation should succeed")
    56  	})
    57  
    58  	t.Run("get obj by ID", func(t *testing.T) {
    59  		params := objects.NewObjectsGetParams().WithID(id)
    60  		obj, err := helper.Client(t).Objects.ObjectsGet(params, nil)
    61  		require.Nil(t, err, "object can be retrieved by id")
    62  
    63  		assert.Equal(t, "Jane Doe", obj.Payload.Properties.(map[string]interface{})["name"].(string))
    64  	})
    65  
    66  	t.Run("tear down", func(t *testing.T) {
    67  		deleteObjectClass(t, "TestSkipVectorIndex")
    68  	})
    69  }