test: update cases for index describe and upsert with autoID (#35191)

issue: #33419

---------

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
This commit is contained in:
ThreadDao 2024-08-05 18:00:16 +08:00 committed by GitHub
parent 1db099973f
commit a62118ca33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 255 additions and 165 deletions

View File

@ -16,6 +16,7 @@ on:
- 'cmd/**' - 'cmd/**'
- 'build/**' - 'build/**'
- 'tests/integration/**' - 'tests/integration/**'
- 'tests/go_client/**'
- '.github/workflows/code-checker.yaml' - '.github/workflows/code-checker.yaml'
- '.env' - '.env'
- docker-compose.yml - docker-compose.yml

View File

@ -15,6 +15,7 @@ on:
- 'cmd/**' - 'cmd/**'
- 'build/**' - 'build/**'
- 'tests/integration/**' - 'tests/integration/**'
- 'tests/go_client/**'
- '.github/workflows/mac.yaml' - '.github/workflows/mac.yaml'
- '.env' - '.env'
- docker-compose.yml - docker-compose.yml

View File

@ -9,9 +9,8 @@ import (
"go.uber.org/zap" "go.uber.org/zap"
"google.golang.org/grpc" "google.golang.org/grpc"
clientv2 "github.com/milvus-io/milvus/client/v2" "github.com/milvus-io/milvus/client/v2"
"github.com/milvus-io/milvus/client/v2/entity" "github.com/milvus-io/milvus/client/v2/entity"
"github.com/milvus-io/milvus/client/v2/index"
"github.com/milvus-io/milvus/pkg/log" "github.com/milvus-io/milvus/pkg/log"
) )
@ -58,12 +57,12 @@ func LoggingUnaryInterceptor() grpc.UnaryClientInterceptor {
} }
type MilvusClient struct { type MilvusClient struct {
mClient *clientv2.Client mClient *client.Client
} }
func NewMilvusClient(ctx context.Context, cfg *clientv2.ClientConfig) (*MilvusClient, error) { func NewMilvusClient(ctx context.Context, cfg *client.ClientConfig) (*MilvusClient, error) {
cfg.DialOptions = append(cfg.DialOptions, grpc.WithUnaryInterceptor(LoggingUnaryInterceptor())) cfg.DialOptions = append(cfg.DialOptions, grpc.WithUnaryInterceptor(LoggingUnaryInterceptor()))
mClient, err := clientv2.New(ctx, cfg) mClient, err := client.New(ctx, cfg)
return &MilvusClient{ return &MilvusClient{
mClient, mClient,
}, err }, err
@ -77,25 +76,25 @@ func (mc *MilvusClient) Close(ctx context.Context) error {
// -- database -- // -- database --
// UsingDatabase list all database in milvus cluster. // UsingDatabase list all database in milvus cluster.
func (mc *MilvusClient) UsingDatabase(ctx context.Context, option clientv2.UsingDatabaseOption) error { func (mc *MilvusClient) UsingDatabase(ctx context.Context, option client.UsingDatabaseOption) error {
err := mc.mClient.UsingDatabase(ctx, option) err := mc.mClient.UsingDatabase(ctx, option)
return err return err
} }
// ListDatabases list all database in milvus cluster. // ListDatabases list all database in milvus cluster.
func (mc *MilvusClient) ListDatabases(ctx context.Context, option clientv2.ListDatabaseOption, callOptions ...grpc.CallOption) ([]string, error) { func (mc *MilvusClient) ListDatabases(ctx context.Context, option client.ListDatabaseOption, callOptions ...grpc.CallOption) ([]string, error) {
databaseNames, err := mc.mClient.ListDatabase(ctx, option, callOptions...) databaseNames, err := mc.mClient.ListDatabase(ctx, option, callOptions...)
return databaseNames, err return databaseNames, err
} }
// CreateDatabase create database with the given name. // CreateDatabase create database with the given name.
func (mc *MilvusClient) CreateDatabase(ctx context.Context, option clientv2.CreateDatabaseOption, callOptions ...grpc.CallOption) error { func (mc *MilvusClient) CreateDatabase(ctx context.Context, option client.CreateDatabaseOption, callOptions ...grpc.CallOption) error {
err := mc.mClient.CreateDatabase(ctx, option, callOptions...) err := mc.mClient.CreateDatabase(ctx, option, callOptions...)
return err return err
} }
// DropDatabase drop database with the given db name. // DropDatabase drop database with the given db name.
func (mc *MilvusClient) DropDatabase(ctx context.Context, option clientv2.DropDatabaseOption, callOptions ...grpc.CallOption) error { func (mc *MilvusClient) DropDatabase(ctx context.Context, option client.DropDatabaseOption, callOptions ...grpc.CallOption) error {
err := mc.mClient.DropDatabase(ctx, option, callOptions...) err := mc.mClient.DropDatabase(ctx, option, callOptions...)
return err return err
} }
@ -103,31 +102,31 @@ func (mc *MilvusClient) DropDatabase(ctx context.Context, option clientv2.DropDa
// -- collection -- // -- collection --
// CreateCollection Create Collection // CreateCollection Create Collection
func (mc *MilvusClient) CreateCollection(ctx context.Context, option clientv2.CreateCollectionOption, callOptions ...grpc.CallOption) error { func (mc *MilvusClient) CreateCollection(ctx context.Context, option client.CreateCollectionOption, callOptions ...grpc.CallOption) error {
err := mc.mClient.CreateCollection(ctx, option, callOptions...) err := mc.mClient.CreateCollection(ctx, option, callOptions...)
return err return err
} }
// ListCollections Create Collection // ListCollections Create Collection
func (mc *MilvusClient) ListCollections(ctx context.Context, option clientv2.ListCollectionOption, callOptions ...grpc.CallOption) ([]string, error) { func (mc *MilvusClient) ListCollections(ctx context.Context, option client.ListCollectionOption, callOptions ...grpc.CallOption) ([]string, error) {
collectionNames, err := mc.mClient.ListCollections(ctx, option, callOptions...) collectionNames, err := mc.mClient.ListCollections(ctx, option, callOptions...)
return collectionNames, err return collectionNames, err
} }
// DescribeCollection Describe collection // DescribeCollection Describe collection
func (mc *MilvusClient) DescribeCollection(ctx context.Context, option clientv2.DescribeCollectionOption, callOptions ...grpc.CallOption) (*entity.Collection, error) { func (mc *MilvusClient) DescribeCollection(ctx context.Context, option client.DescribeCollectionOption, callOptions ...grpc.CallOption) (*entity.Collection, error) {
collection, err := mc.mClient.DescribeCollection(ctx, option, callOptions...) collection, err := mc.mClient.DescribeCollection(ctx, option, callOptions...)
return collection, err return collection, err
} }
// HasCollection Has collection // HasCollection Has collection
func (mc *MilvusClient) HasCollection(ctx context.Context, option clientv2.HasCollectionOption, callOptions ...grpc.CallOption) (bool, error) { func (mc *MilvusClient) HasCollection(ctx context.Context, option client.HasCollectionOption, callOptions ...grpc.CallOption) (bool, error) {
has, err := mc.mClient.HasCollection(ctx, option, callOptions...) has, err := mc.mClient.HasCollection(ctx, option, callOptions...)
return has, err return has, err
} }
// DropCollection Drop Collection // DropCollection Drop Collection
func (mc *MilvusClient) DropCollection(ctx context.Context, option clientv2.DropCollectionOption, callOptions ...grpc.CallOption) error { func (mc *MilvusClient) DropCollection(ctx context.Context, option client.DropCollectionOption, callOptions ...grpc.CallOption) error {
err := mc.mClient.DropCollection(ctx, option, callOptions...) err := mc.mClient.DropCollection(ctx, option, callOptions...)
return err return err
} }
@ -135,31 +134,31 @@ func (mc *MilvusClient) DropCollection(ctx context.Context, option clientv2.Drop
// -- partition -- // -- partition --
// CreatePartition Create Partition // CreatePartition Create Partition
func (mc *MilvusClient) CreatePartition(ctx context.Context, option clientv2.CreatePartitionOption, callOptions ...grpc.CallOption) error { func (mc *MilvusClient) CreatePartition(ctx context.Context, option client.CreatePartitionOption, callOptions ...grpc.CallOption) error {
err := mc.mClient.CreatePartition(ctx, option, callOptions...) err := mc.mClient.CreatePartition(ctx, option, callOptions...)
return err return err
} }
// DropPartition Drop Partition // DropPartition Drop Partition
func (mc *MilvusClient) DropPartition(ctx context.Context, option clientv2.DropPartitionOption, callOptions ...grpc.CallOption) error { func (mc *MilvusClient) DropPartition(ctx context.Context, option client.DropPartitionOption, callOptions ...grpc.CallOption) error {
err := mc.mClient.DropPartition(ctx, option, callOptions...) err := mc.mClient.DropPartition(ctx, option, callOptions...)
return err return err
} }
// HasPartition Has Partition // HasPartition Has Partition
func (mc *MilvusClient) HasPartition(ctx context.Context, option clientv2.HasPartitionOption, callOptions ...grpc.CallOption) (bool, error) { func (mc *MilvusClient) HasPartition(ctx context.Context, option client.HasPartitionOption, callOptions ...grpc.CallOption) (bool, error) {
has, err := mc.mClient.HasPartition(ctx, option, callOptions...) has, err := mc.mClient.HasPartition(ctx, option, callOptions...)
return has, err return has, err
} }
// ListPartitions List Partitions // ListPartitions List Partitions
func (mc *MilvusClient) ListPartitions(ctx context.Context, option clientv2.ListPartitionsOption, callOptions ...grpc.CallOption) ([]string, error) { func (mc *MilvusClient) ListPartitions(ctx context.Context, option client.ListPartitionsOption, callOptions ...grpc.CallOption) ([]string, error) {
partitionNames, err := mc.mClient.ListPartitions(ctx, option, callOptions...) partitionNames, err := mc.mClient.ListPartitions(ctx, option, callOptions...)
return partitionNames, err return partitionNames, err
} }
// LoadPartitions Load Partitions into memory // LoadPartitions Load Partitions into memory
func (mc *MilvusClient) LoadPartitions(ctx context.Context, option clientv2.LoadPartitionsOption, callOptions ...grpc.CallOption) (clientv2.LoadTask, error) { func (mc *MilvusClient) LoadPartitions(ctx context.Context, option client.LoadPartitionsOption, callOptions ...grpc.CallOption) (client.LoadTask, error) {
loadTask, err := mc.mClient.LoadPartitions(ctx, option, callOptions...) loadTask, err := mc.mClient.LoadPartitions(ctx, option, callOptions...)
return loadTask, err return loadTask, err
} }
@ -167,25 +166,25 @@ func (mc *MilvusClient) LoadPartitions(ctx context.Context, option clientv2.Load
// -- index -- // -- index --
// CreateIndex Create Index // CreateIndex Create Index
func (mc *MilvusClient) CreateIndex(ctx context.Context, option clientv2.CreateIndexOption, callOptions ...grpc.CallOption) (*clientv2.CreateIndexTask, error) { func (mc *MilvusClient) CreateIndex(ctx context.Context, option client.CreateIndexOption, callOptions ...grpc.CallOption) (*client.CreateIndexTask, error) {
createIndexTask, err := mc.mClient.CreateIndex(ctx, option, callOptions...) createIndexTask, err := mc.mClient.CreateIndex(ctx, option, callOptions...)
return createIndexTask, err return createIndexTask, err
} }
// ListIndexes List Indexes // ListIndexes List Indexes
func (mc *MilvusClient) ListIndexes(ctx context.Context, option clientv2.ListIndexOption, callOptions ...grpc.CallOption) ([]string, error) { func (mc *MilvusClient) ListIndexes(ctx context.Context, option client.ListIndexOption, callOptions ...grpc.CallOption) ([]string, error) {
indexes, err := mc.mClient.ListIndexes(ctx, option, callOptions...) indexes, err := mc.mClient.ListIndexes(ctx, option, callOptions...)
return indexes, err return indexes, err
} }
// DescribeIndex Describe Index // DescribeIndex Describe Index
func (mc *MilvusClient) DescribeIndex(ctx context.Context, option clientv2.DescribeIndexOption, callOptions ...grpc.CallOption) (index.Index, error) { func (mc *MilvusClient) DescribeIndex(ctx context.Context, option client.DescribeIndexOption, callOptions ...grpc.CallOption) (client.IndexDescription, error) {
idx, err := mc.mClient.DescribeIndex(ctx, option, callOptions...) idxDesc, err := mc.mClient.DescribeIndex(ctx, option, callOptions...)
return idx, err return idxDesc, err
} }
// DropIndex Drop Index // DropIndex Drop Index
func (mc *MilvusClient) DropIndex(ctx context.Context, option clientv2.DropIndexOption, callOptions ...grpc.CallOption) error { func (mc *MilvusClient) DropIndex(ctx context.Context, option client.DropIndexOption, callOptions ...grpc.CallOption) error {
err := mc.mClient.DropIndex(ctx, option, callOptions...) err := mc.mClient.DropIndex(ctx, option, callOptions...)
return err return err
} }
@ -193,7 +192,7 @@ func (mc *MilvusClient) DropIndex(ctx context.Context, option clientv2.DropIndex
// -- write -- // -- write --
// Insert insert data // Insert insert data
func (mc *MilvusClient) Insert(ctx context.Context, option clientv2.InsertOption, callOptions ...grpc.CallOption) (clientv2.InsertResult, error) { func (mc *MilvusClient) Insert(ctx context.Context, option client.InsertOption, callOptions ...grpc.CallOption) (client.InsertResult, error) {
insertRes, err := mc.mClient.Insert(ctx, option, callOptions...) insertRes, err := mc.mClient.Insert(ctx, option, callOptions...)
if err == nil { if err == nil {
log.Info("Insert", zap.Any("result", insertRes)) log.Info("Insert", zap.Any("result", insertRes))
@ -202,19 +201,19 @@ func (mc *MilvusClient) Insert(ctx context.Context, option clientv2.InsertOption
} }
// Flush flush data // Flush flush data
func (mc *MilvusClient) Flush(ctx context.Context, option clientv2.FlushOption, callOptions ...grpc.CallOption) (*clientv2.FlushTask, error) { func (mc *MilvusClient) Flush(ctx context.Context, option client.FlushOption, callOptions ...grpc.CallOption) (*client.FlushTask, error) {
flushTask, err := mc.mClient.Flush(ctx, option, callOptions...) flushTask, err := mc.mClient.Flush(ctx, option, callOptions...)
return flushTask, err return flushTask, err
} }
// Delete deletes data // Delete deletes data
func (mc *MilvusClient) Delete(ctx context.Context, option clientv2.DeleteOption, callOptions ...grpc.CallOption) (clientv2.DeleteResult, error) { func (mc *MilvusClient) Delete(ctx context.Context, option client.DeleteOption, callOptions ...grpc.CallOption) (client.DeleteResult, error) {
deleteRes, err := mc.mClient.Delete(ctx, option, callOptions...) deleteRes, err := mc.mClient.Delete(ctx, option, callOptions...)
return deleteRes, err return deleteRes, err
} }
// Upsert upsert data // Upsert upsert data
func (mc *MilvusClient) Upsert(ctx context.Context, option clientv2.UpsertOption, callOptions ...grpc.CallOption) (clientv2.UpsertResult, error) { func (mc *MilvusClient) Upsert(ctx context.Context, option client.UpsertOption, callOptions ...grpc.CallOption) (client.UpsertResult, error) {
upsertRes, err := mc.mClient.Upsert(ctx, option, callOptions...) upsertRes, err := mc.mClient.Upsert(ctx, option, callOptions...)
return upsertRes, err return upsertRes, err
} }
@ -222,19 +221,19 @@ func (mc *MilvusClient) Upsert(ctx context.Context, option clientv2.UpsertOption
// -- read -- // -- read --
// LoadCollection Load Collection // LoadCollection Load Collection
func (mc *MilvusClient) LoadCollection(ctx context.Context, option clientv2.LoadCollectionOption, callOptions ...grpc.CallOption) (clientv2.LoadTask, error) { func (mc *MilvusClient) LoadCollection(ctx context.Context, option client.LoadCollectionOption, callOptions ...grpc.CallOption) (client.LoadTask, error) {
loadTask, err := mc.mClient.LoadCollection(ctx, option, callOptions...) loadTask, err := mc.mClient.LoadCollection(ctx, option, callOptions...)
return loadTask, err return loadTask, err
} }
// Search search from collection // Search search from collection
func (mc *MilvusClient) Search(ctx context.Context, option clientv2.SearchOption, callOptions ...grpc.CallOption) ([]clientv2.ResultSet, error) { func (mc *MilvusClient) Search(ctx context.Context, option client.SearchOption, callOptions ...grpc.CallOption) ([]client.ResultSet, error) {
resultSets, err := mc.mClient.Search(ctx, option, callOptions...) resultSets, err := mc.mClient.Search(ctx, option, callOptions...)
return resultSets, err return resultSets, err
} }
// Query query from collection // Query query from collection
func (mc *MilvusClient) Query(ctx context.Context, option clientv2.QueryOption, callOptions ...grpc.CallOption) (clientv2.ResultSet, error) { func (mc *MilvusClient) Query(ctx context.Context, option client.QueryOption, callOptions ...grpc.CallOption) (client.ResultSet, error) {
resultSet, err := mc.mClient.Query(ctx, option, callOptions...) resultSet, err := mc.mClient.Query(ctx, option, callOptions...)
return resultSet, err return resultSet, err
} }

View File

@ -1,5 +1,7 @@
package common package common
import "github.com/milvus-io/milvus/client/v2/index"
// cost default field name // cost default field name
const ( const (
DefaultInt8FieldName = "int8" DefaultInt8FieldName = "int8"
@ -65,3 +67,12 @@ const (
MaxVectorFieldNum = 4 MaxVectorFieldNum = 4
MaxShardNum = 16 MaxShardNum = 16
) )
const (
IndexStateIndexStateNone index.IndexState = 0
IndexStateUnissued index.IndexState = 1
IndexStateInProgress index.IndexState = 2
IndexStateFinished index.IndexState = 3
IndexStateFailed index.IndexState = 4
IndexStateRetry index.IndexState = 5
)

View File

@ -9,9 +9,10 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.uber.org/zap" "go.uber.org/zap"
clientv2 "github.com/milvus-io/milvus/client/v2" "github.com/milvus-io/milvus/client/v2"
"github.com/milvus-io/milvus/client/v2/column" "github.com/milvus-io/milvus/client/v2/column"
"github.com/milvus-io/milvus/client/v2/entity" "github.com/milvus-io/milvus/client/v2/entity"
"github.com/milvus-io/milvus/client/v2/index"
"github.com/milvus-io/milvus/pkg/log" "github.com/milvus-io/milvus/pkg/log"
) )
@ -123,7 +124,7 @@ func EqualArrayColumn(t *testing.T, columnA column.Column, columnB column.Column
} }
// CheckInsertResult check insert result, ids len (insert count), ids data (pks, but no auto ids) // CheckInsertResult check insert result, ids len (insert count), ids data (pks, but no auto ids)
func CheckInsertResult(t *testing.T, expIds column.Column, insertRes clientv2.InsertResult) { func CheckInsertResult(t *testing.T, expIds column.Column, insertRes client.InsertResult) {
require.Equal(t, expIds.Len(), insertRes.IDs.Len()) require.Equal(t, expIds.Len(), insertRes.IDs.Len())
require.Equal(t, expIds.Len(), int(insertRes.InsertCount)) require.Equal(t, expIds.Len(), int(insertRes.InsertCount))
actualIds := insertRes.IDs actualIds := insertRes.IDs
@ -149,7 +150,7 @@ func CheckOutputFields(t *testing.T, expFields []string, actualColumns []column.
} }
// CheckSearchResult check search result, check nq, topk, ids, score // CheckSearchResult check search result, check nq, topk, ids, score
func CheckSearchResult(t *testing.T, actualSearchResults []clientv2.ResultSet, expNq int, expTopK int) { func CheckSearchResult(t *testing.T, actualSearchResults []client.ResultSet, expNq int, expTopK int) {
require.Equal(t, len(actualSearchResults), expNq) require.Equal(t, len(actualSearchResults), expNq)
require.Len(t, actualSearchResults, expNq) require.Len(t, actualSearchResults, expNq)
for _, actualSearchResult := range actualSearchResults { for _, actualSearchResult := range actualSearchResults {
@ -176,3 +177,44 @@ func CheckQueryResult(t *testing.T, expColumns []column.Column, actualColumns []
} }
} }
} }
// GenColumnDataOption -- create column data --
type checkIndexOpt struct {
state index.IndexState
pendingIndexRows int64
totalRows int64
indexedRows int64
}
func TNewCheckIndexOpt(totalRows int64) *checkIndexOpt {
return &checkIndexOpt{
state: IndexStateFinished,
totalRows: totalRows,
pendingIndexRows: 0,
indexedRows: totalRows,
}
}
func (opt *checkIndexOpt) TWithIndexState(state index.IndexState) *checkIndexOpt {
opt.state = state
return opt
}
func (opt *checkIndexOpt) TWithIndexRows(totalRows int64, indexedRows int64, pendingIndexRows int64) *checkIndexOpt {
opt.totalRows = totalRows
opt.indexedRows = indexedRows
opt.pendingIndexRows = pendingIndexRows
return opt
}
func CheckIndex(t *testing.T, actualIdxDesc client.IndexDescription, idx index.Index, opt *checkIndexOpt) {
require.EqualValuesf(t, idx, actualIdxDesc.Index, "Actual index is not same with expected index")
require.Equal(t, actualIdxDesc.TotalRows, actualIdxDesc.PendingIndexRows+actualIdxDesc.IndexedRows)
if opt != nil {
require.Equal(t, opt.totalRows, opt.pendingIndexRows+opt.indexedRows)
require.Equal(t, opt.state, actualIdxDesc.State)
require.Equal(t, opt.totalRows, actualIdxDesc.TotalRows)
require.Equal(t, opt.indexedRows, actualIdxDesc.IndexedRows)
require.Equal(t, opt.pendingIndexRows, actualIdxDesc.PendingIndexRows)
}
}

View File

@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.11 toolchain go1.21.11
require ( require (
github.com/milvus-io/milvus/client/v2 v2.0.0-20240729131949-a8a4779749de github.com/milvus-io/milvus/client/v2 v2.0.0-20240805024817-4b553b0333f4
github.com/milvus-io/milvus/pkg v0.0.2-0.20240801085213-a642a26ed4c6 github.com/milvus-io/milvus/pkg v0.0.2-0.20240801085213-a642a26ed4c6
github.com/quasilyte/go-ruleguard/dsl v0.3.22 github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/stretchr/testify v1.9.0 github.com/stretchr/testify v1.9.0
@ -14,6 +14,8 @@ require (
google.golang.org/grpc v1.65.0 google.golang.org/grpc v1.65.0
) )
replace github.com/milvus-io/milvus/client/v2 v2.0.0-20240805024817-4b553b0333f4 => ../../../milvus/client
require ( require (
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect github.com/blang/semver/v4 v4.0.0 // indirect
@ -114,7 +116,7 @@ require (
golang.org/x/sys v0.22.0 // indirect golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.5.0 // indirect golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf // indirect
google.golang.org/protobuf v1.34.2 // indirect google.golang.org/protobuf v1.34.2 // indirect

View File

@ -390,8 +390,8 @@ github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/le
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240717062137-3ffb1db01632 h1:CXig0DNtUsCLzchCFe3PR2KgOdobbz9gK2nSV7195PM= github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240717062137-3ffb1db01632 h1:CXig0DNtUsCLzchCFe3PR2KgOdobbz9gK2nSV7195PM=
github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240717062137-3ffb1db01632/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs= github.com/milvus-io/milvus-proto/go-api/v2 v2.3.4-0.20240717062137-3ffb1db01632/go.mod h1:/6UT4zZl6awVeXLeE7UGDWZvXj3IWkRsh3mqsn0DiAs=
github.com/milvus-io/milvus/client/v2 v2.0.0-20240729131949-a8a4779749de h1:GtxjVQ5VfGNf/bEN/K4zKCnVXtq7PkSsniWVlAF7GlI= github.com/milvus-io/milvus/client/v2 v2.0.0-20240805024817-4b553b0333f4 h1:0VEsc69duq3NMNRYWq0qtJDN6HSj13USju1ZdlmvUo0=
github.com/milvus-io/milvus/client/v2 v2.0.0-20240729131949-a8a4779749de/go.mod h1:CGX8NwpP5T7tSDzYOBJDgyW1PK/vNixosoR8r5BMqMA= github.com/milvus-io/milvus/client/v2 v2.0.0-20240805024817-4b553b0333f4/go.mod h1:p2fU+bPgEy+OBYUvhE1+ABEp3KaFQyY586DSs6iEDHk=
github.com/milvus-io/milvus/pkg v0.0.2-0.20240801085213-a642a26ed4c6 h1:dotu470D/DkctdLHsTCCmuvAD3h5C8gkFhMxb0Zlu7A= github.com/milvus-io/milvus/pkg v0.0.2-0.20240801085213-a642a26ed4c6 h1:dotu470D/DkctdLHsTCCmuvAD3h5C8gkFhMxb0Zlu7A=
github.com/milvus-io/milvus/pkg v0.0.2-0.20240801085213-a642a26ed4c6/go.mod h1:tdeEcpeaAcrIJgrr6LVzu7SYl9zn18dNKZwPmCUb0Io= github.com/milvus-io/milvus/pkg v0.0.2-0.20240801085213-a642a26ed4c6/go.mod h1:tdeEcpeaAcrIJgrr6LVzu7SYl9zn18dNKZwPmCUb0Io=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
@ -1014,8 +1014,8 @@ google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6D
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A=
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24=
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d h1:VBu5YqKPv6XiJ199exd8Br+Aetz+o08F+PLMnwJQHAY= google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ=
google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d/go.mod h1:yZTlhN0tQnXo3h00fuXNCxJdLdIdnVFVBaRJ5LWBbw4= google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 h1:7whR9kGa5LUwFtpLm2ArCEejtnxlGeLbAyjFY8sGNFw=
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU= google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157/go.mod h1:99sLkeliLXfdj2J75X3Ho+rrVCaJze0uwN7zDDkjPVU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf h1:liao9UHurZLtiEwBgT9LMOnKYsHze6eA6w1KQCMVN2Q= google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf h1:liao9UHurZLtiEwBgT9LMOnKYsHze6eA6w1KQCMVN2Q=

View File

@ -937,7 +937,7 @@ func TestCreateCollectionInvalid(t *testing.T) {
} }
vecField := entity.NewField().WithName("vec").WithDataType(entity.FieldTypeFloatVector).WithDim(8) vecField := entity.NewField().WithName("vec").WithDataType(entity.FieldTypeFloatVector).WithDim(8)
mSchemaErrs := []mSchemaErr{ mSchemaErrs := []mSchemaErr{
{schema: nil, errMsg: "duplicated field name"}, {schema: nil, errMsg: "schema does not contain vector field"},
{schema: entity.NewSchema().WithField(vecField), errMsg: "collection name should not be empty"}, // no collection name {schema: entity.NewSchema().WithField(vecField), errMsg: "collection name should not be empty"}, // no collection name
{schema: entity.NewSchema().WithName("aaa").WithField(vecField), errMsg: "primary key is not specified"}, // no pk field {schema: entity.NewSchema().WithName("aaa").WithField(vecField), errMsg: "primary key is not specified"}, // no pk field
{schema: entity.NewSchema().WithName("aaa").WithField(vecField).WithField(entity.NewField()), errMsg: "primary key is not specified"}, {schema: entity.NewSchema().WithName("aaa").WithField(vecField).WithField(entity.NewField()), errMsg: "primary key is not specified"},

View File

@ -24,7 +24,7 @@ func TestDelete(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load collection // index and load collection
@ -60,7 +60,7 @@ func TestDeleteVarcharPks(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load collection // index and load collection
@ -138,7 +138,7 @@ func TestDeleteComplexExprWithoutLoad(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
idsPk := []int64{0, 1, 2, 3, 4} idsPk := []int64{0, 1, 2, 3, 4}
@ -201,7 +201,7 @@ func TestDeleteVarcharEmptyIds(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load collection // index and load collection
@ -305,8 +305,8 @@ func TestDeleteDefaultPartitionName(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
// insert [0, 3000) into default, insert [3000, 6000) into p1 // insert [0, 3000) into default, insert [3000, 6000) into p1
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load // index and load
@ -343,8 +343,8 @@ func TestDeleteEmptyPartitionName(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
// insert [0, 3000) into default, insert [3000, 6000) into p1 // insert [0, 3000) into default, insert [3000, 6000) into p1
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load // index and load
@ -381,8 +381,8 @@ func TestDeletePartitionName(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
// insert [0, 3000) into default, insert [3000, 6000) into parName // insert [0, 3000) into default, insert [3000, 6000) into parName
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load // index and load
@ -485,7 +485,7 @@ func TestDeleteComplexExpr(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert [0, 3000) into default // insert [0, 3000) into default
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithMaxCapacity(common.TestCapacity)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithMaxCapacity(common.TestCapacity))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load // index and load
@ -514,7 +514,7 @@ func TestDeleteInvalidExpr(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert [0, 3000) into default // insert [0, 3000) into default
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithMaxCapacity(common.TestCapacity)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithMaxCapacity(common.TestCapacity))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load // index and load
@ -537,7 +537,7 @@ func TestDeleteDuplicatedPks(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption().TWithIsDynamic(true), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption().TWithIsDynamic(true), hp.TNewSchemaOption())
// insert [0, 3000) into default // insert [0, 3000) into default
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithMaxCapacity(common.TestCapacity)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithMaxCapacity(common.TestCapacity))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index and load // index and load

View File

@ -20,7 +20,7 @@ type InsertParams struct {
IsRows bool IsRows bool
} }
func NewInsertParams(schema *entity.Schema, nb int) *InsertParams { func NewInsertParams(schema *entity.Schema) *InsertParams {
return &InsertParams{ return &InsertParams{
Schema: schema, Schema: schema,
} }

View File

@ -25,7 +25,7 @@ func TestIndexVectorDefault(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -40,7 +40,7 @@ func TestIndexVectorDefault(t *testing.T) {
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, fieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, fieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, index.NewGenericIndex(fieldName, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(fieldName, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, descIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, descIdx.Name()))
@ -58,7 +58,7 @@ func TestIndexVectorIP(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -74,7 +74,7 @@ func TestIndexVectorIP(t *testing.T) {
expIdx := index.NewGenericIndex(fieldName, idx.Params()) expIdx := index.NewGenericIndex(fieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, fieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, fieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIdx, descIdx) common.CheckIndex(t, descIdx, expIdx, common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name()))
@ -92,7 +92,7 @@ func TestIndexVectorCosine(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -108,7 +108,7 @@ func TestIndexVectorCosine(t *testing.T) {
expIdx := index.NewGenericIndex(fieldName, idx.Params()) expIdx := index.NewGenericIndex(fieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, fieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, fieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIdx, descIdx) common.CheckIndex(t, descIdx, expIdx, common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name()))
@ -126,7 +126,7 @@ func TestIndexAutoFloatVector(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -146,7 +146,7 @@ func TestIndexAutoFloatVector(t *testing.T) {
expIdx := index.NewGenericIndex(common.DefaultFloatVecFieldName, idx.Params()) expIdx := index.NewGenericIndex(common.DefaultFloatVecFieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIdx, descIdx) common.CheckIndex(t, descIdx, expIdx, common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name()))
@ -163,7 +163,7 @@ func TestIndexAutoBinaryVector(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -187,7 +187,7 @@ func TestIndexAutoBinaryVector(t *testing.T) {
expIdx := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params()) expIdx := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIdx, descIdx) common.CheckIndex(t, descIdx, expIdx, common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name()))
@ -204,7 +204,7 @@ func TestIndexAutoSparseVector(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -225,7 +225,7 @@ func TestIndexAutoSparseVector(t *testing.T) {
expIdx := index.NewGenericIndex(common.DefaultSparseVecFieldName, idx.Params()) expIdx := index.NewGenericIndex(common.DefaultSparseVecFieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultSparseVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultSparseVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIdx, descIdx) common.CheckIndex(t, descIdx, expIdx, common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name()))
@ -241,17 +241,17 @@ func TestCreateAutoIndexAllFields(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
var expFields []string var expFields []string
var idx index.Index var idx index.Index
for _, field := range schema.Fields { for _, field := range schema.Fields {
if field.DataType == entity.FieldTypeArray || field.DataType == entity.FieldTypeJSON { if field.DataType == entity.FieldTypeJSON {
idx = index.NewAutoIndex(entity.IP) idx = index.NewAutoIndex(entity.IP)
_, err := mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, field.Name, idx)) _, err := mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, field.Name, idx))
common.CheckErr(t, err, false, fmt.Sprintf("create auto index on %s field is not supported", field.DataType)) common.CheckErr(t, err, false, fmt.Sprintf("create auto index on type:%s is not supported", field.DataType))
} else { } else {
if field.DataType == entity.FieldTypeBinaryVector { if field.DataType == entity.FieldTypeBinaryVector {
idx = index.NewAutoIndex(entity.JACCARD) idx = index.NewAutoIndex(entity.JACCARD)
@ -266,7 +266,7 @@ func TestCreateAutoIndexAllFields(t *testing.T) {
// describe index // describe index
descIdx, descErr := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name)) descIdx, descErr := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name))
common.CheckErr(t, descErr, true) common.CheckErr(t, descErr, true)
require.EqualValues(t, index.NewGenericIndex(field.Name, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(field.Name, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
} }
expFields = append(expFields, field.Name) expFields = append(expFields, field.Name)
} }
@ -287,7 +287,7 @@ func TestIndexBinaryFlat(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -302,7 +302,7 @@ func TestIndexBinaryFlat(t *testing.T) {
expIdx := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params()) expIdx := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIdx, descIdx) common.CheckIndex(t, descIdx, expIdx, common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name()))
@ -318,7 +318,7 @@ func TestIndexBinaryIvfFlat(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -333,7 +333,7 @@ func TestIndexBinaryIvfFlat(t *testing.T) {
expIdx := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params()) expIdx := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIdx, descIdx) common.CheckIndex(t, descIdx, expIdx, common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name())) err = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, expIdx.Name()))
@ -350,7 +350,7 @@ func TestCreateBinaryIndexNotSupportedMetricType(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -415,7 +415,7 @@ func TestCreateTrieScalarIndex(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -433,7 +433,7 @@ func TestCreateTrieScalarIndex(t *testing.T) {
expIndex := index.NewGenericIndex(field.Name, idx.Params()) expIndex := index.NewGenericIndex(field.Name, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIndex, descIdx) common.CheckIndex(t, descIdx, expIndex, common.TNewCheckIndexOpt(common.DefaultNb))
} else { } else {
_, err := mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, field.Name, idx)) _, err := mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, field.Name, idx))
common.CheckErr(t, err, false, "TRIE are only supported on varchar field") common.CheckErr(t, err, false, "TRIE are only supported on varchar field")
@ -451,7 +451,7 @@ func TestCreateSortedScalarIndex(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
@ -474,7 +474,7 @@ func TestCreateSortedScalarIndex(t *testing.T) {
expIndex := index.NewGenericIndex(field.Name, idx.Params()) expIndex := index.NewGenericIndex(field.Name, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIndex, descIdx) common.CheckIndex(t, descIdx, expIndex, common.TNewCheckIndexOpt(common.DefaultNb))
} }
} }
} }
@ -501,7 +501,7 @@ func TestCreateInvertedScalarIndex(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
@ -518,7 +518,7 @@ func TestCreateInvertedScalarIndex(t *testing.T) {
// describe index // describe index
expIndex := index.NewGenericIndex(field.Name, idx.Params()) expIndex := index.NewGenericIndex(field.Name, idx.Params())
_index, _ := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name)) _index, _ := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name))
require.EqualValues(t, expIndex, _index) common.CheckIndex(t, _index, expIndex, common.TNewCheckIndexOpt(common.DefaultNb))
} }
} }
// load -> search and output all fields // load -> search and output all fields
@ -544,7 +544,7 @@ func TestCreateScalarIndexVectorField(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -568,7 +568,7 @@ func TestCreateIndexWithOtherFieldName(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -583,7 +583,7 @@ func TestCreateIndexWithOtherFieldName(t *testing.T) {
expIndex := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params()) expIndex := index.NewGenericIndex(common.DefaultBinaryVecFieldName, idx.Params())
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultBinaryVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, expIndex, descIdx) common.CheckIndex(t, descIdx, expIndex, common.TNewCheckIndexOpt(common.DefaultNb))
// create index in binary field with default name // create index in binary field with default name
idxBinary := index.NewBinFlatIndex(entity.JACCARD) idxBinary := index.NewBinFlatIndex(entity.JACCARD)
@ -600,7 +600,7 @@ func TestCreateIndexJsonField(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -634,7 +634,7 @@ func TestCreateUnsupportedIndexArrayField(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
type scalarIndexError struct { type scalarIndexError struct {
@ -672,7 +672,7 @@ func TestCreateInvertedIndexArrayField(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
@ -710,7 +710,7 @@ func TestCreateIndexWithoutName(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -725,7 +725,7 @@ func TestCreateIndexWithoutName(t *testing.T) {
idxDesc, _ := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName)) idxDesc, _ := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName))
expIndex := index.NewGenericIndex(common.DefaultFloatVecFieldName, idx.Params()) expIndex := index.NewGenericIndex(common.DefaultFloatVecFieldName, idx.Params())
require.Equal(t, common.DefaultFloatVecFieldName, idxDesc.Name()) require.Equal(t, common.DefaultFloatVecFieldName, idxDesc.Name())
require.EqualValues(t, expIndex, idxDesc) common.CheckIndex(t, idxDesc, expIndex, common.TNewCheckIndexOpt(common.DefaultNb))
} }
// test create index on same field twice // test create index on same field twice
@ -737,20 +737,21 @@ func TestCreateIndexDup(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption())
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// index dup // index dup
idxHnsw := index.NewHNSWIndex(entity.L2, 8, 96) idxHnsw := index.NewHNSWIndex(entity.L2, 8, 96)
idxIvfSq8 := index.NewIvfSQ8Index(entity.L2, 128) idxIvfSq8 := index.NewIvfSQ8Index(entity.L2, 128)
_, err := mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName, idxHnsw)) idxTask, err := mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName, idxHnsw))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
idxTask.Await(ctx)
// describe index // describe index
_index, _ := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName)) _index, _ := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName))
expIndex := index.NewGenericIndex(common.DefaultFloatVecFieldName, idxHnsw.Params()) expIndex := index.NewGenericIndex(common.DefaultFloatVecFieldName, idxHnsw.Params())
require.EqualValues(t, expIndex, _index) common.CheckIndex(t, _index, expIndex, common.TNewCheckIndexOpt(common.DefaultNb))
_, err = mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName, idxIvfSq8)) _, err = mc.CreateIndex(ctx, client.NewCreateIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName, idxIvfSq8))
common.CheckErr(t, err, false, "CreateIndex failed: at most one distinct index is allowed per field") common.CheckErr(t, err, false, "CreateIndex failed: at most one distinct index is allowed per field")
@ -769,7 +770,7 @@ func TestCreateIndexSparseVectorGeneric(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100)) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -781,7 +782,7 @@ func TestCreateIndexSparseVectorGeneric(t *testing.T) {
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultSparseVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultSparseVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, index.NewGenericIndex(common.DefaultSparseVecFieldName, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(common.DefaultSparseVecFieldName, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
} }
} }
@ -797,7 +798,7 @@ func TestCreateIndexSparseVector(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100)) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -808,7 +809,7 @@ func TestCreateIndexSparseVector(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultSparseVecFieldName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, common.DefaultSparseVecFieldName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, index.NewGenericIndex(common.DefaultSparseVecFieldName, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(common.DefaultSparseVecFieldName, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
} }
} }
@ -820,7 +821,7 @@ func TestCreateSparseIndexInvalidParams(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100)) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -856,7 +857,7 @@ func TestCreateSparseUnsupportedIndex(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100)) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -886,7 +887,7 @@ func TestCreateIndexGeneric(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100)) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -900,7 +901,7 @@ func TestCreateIndexGeneric(t *testing.T) {
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, field.Name))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, index.NewGenericIndex(field.Name, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(field.Name, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
} }
} }
@ -1041,7 +1042,7 @@ func TestCreateIndexAsync(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100)) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption().TWithSparseMaxLen(100))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -1063,7 +1064,7 @@ func TestIndexMultiVectorDupName(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -1091,7 +1092,7 @@ func TestDropIndex(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -1110,21 +1111,21 @@ func TestDropIndex(t *testing.T) {
// describe index with index name -> ok // describe index with index name -> ok
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, index.NewGenericIndex(idxName, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(idxName, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
// drop index with field name // drop index with field name
errDrop := mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName)) errDrop := mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, common.DefaultFloatVecFieldName))
common.CheckErr(t, errDrop, true) common.CheckErr(t, errDrop, true)
descIdx, err = mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName)) descIdx, err = mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, index.NewGenericIndex(idxName, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(idxName, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
// drop index with index name // drop index with index name
errDrop = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, idxName)) errDrop = mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, errDrop, true) common.CheckErr(t, errDrop, true)
_idx, errDescribe := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName)) _idx, errDescribe := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, errDescribe, false, "index not found") common.CheckErr(t, errDescribe, false, "index not found")
require.Nil(t, _idx) common.CheckIndex(t, _idx, nil, nil)
} }
func TestDropIndexCreateIndexWithIndexName(t *testing.T) { func TestDropIndexCreateIndexWithIndexName(t *testing.T) {
@ -1135,7 +1136,7 @@ func TestDropIndexCreateIndexWithIndexName(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, cp, hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
// insert // insert
ip := hp.NewInsertParams(schema, common.DefaultNb) ip := hp.NewInsertParams(schema)
prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, ip, hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -1149,14 +1150,15 @@ func TestDropIndexCreateIndexWithIndexName(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName)) descIdx, err := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
require.EqualValues(t, index.NewGenericIndex(idxName, idx.Params()), descIdx) common.CheckIndex(t, descIdx, index.NewGenericIndex(idxName, idx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
// drop index // drop index
errDrop := mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, idxName)) errDrop := mc.DropIndex(ctx, client.NewDropIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, errDrop, true) common.CheckErr(t, errDrop, true)
_idx, errDescribe := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName)) _idx, errDescribe := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, errDescribe, false, "index not found") common.CheckErr(t, errDescribe, false, "index not found")
require.Nil(t, _idx) common.CheckIndex(t, _idx, nil, common.TNewCheckIndexOpt(0).TWithIndexRows(0, 0, 0).
TWithIndexState(common.IndexStateIndexStateNone))
// create new IP index // create new IP index
ipIdx := index.NewHNSWIndex(entity.IP, 8, 96) ipIdx := index.NewHNSWIndex(entity.IP, 8, 96)
@ -1166,5 +1168,5 @@ func TestDropIndexCreateIndexWithIndexName(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
descIdx2, err2 := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName)) descIdx2, err2 := mc.DescribeIndex(ctx, client.NewDescribeIndexOption(schema.CollectionName, idxName))
common.CheckErr(t, err2, true) common.CheckErr(t, err2, true)
require.EqualValues(t, index.NewGenericIndex(idxName, ipIdx.Params()), descIdx2) common.CheckIndex(t, descIdx2, index.NewGenericIndex(idxName, ipIdx.Params()), common.TNewCheckIndexOpt(common.DefaultNb))
} }

View File

@ -379,7 +379,7 @@ func TestInsertColumnVarcharExceedLen(t *testing.T) {
vecColumn := hp.GenColumnData(100, entity.FieldTypeBinaryVector, *hp.TNewDataOption()) vecColumn := hp.GenColumnData(100, entity.FieldTypeBinaryVector, *hp.TNewDataOption())
_, err := mc.Insert(ctx, client.NewColumnBasedInsertOption(schema.CollectionName, pkColumn, vecColumn)) _, err := mc.Insert(ctx, client.NewColumnBasedInsertOption(schema.CollectionName, pkColumn, vecColumn))
common.CheckErr(t, err, false, "the length (12) of 0th VarChar varchar exceeds max length (0)%!(EXTRA int64=10)") common.CheckErr(t, err, false, "length of varchar field varchar exceeds max length")
} }
// test insert sparse vector // test insert sparse vector

View File

@ -182,7 +182,7 @@ func TestDropPartitionData(t *testing.T) {
require.Truef(t, has, "should has partition") require.Truef(t, has, "should has partition")
// insert data into partition -> query check // insert data into partition -> query check
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb).TWithPartitionName(parName), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema).TWithPartitionName(parName), hp.TNewDataOption())
res, errQ := mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithConsistencyLevel(entity.ClStrong).WithPartitions([]string{parName}).WithOutputFields([]string{common.QueryCountFieldName})) res, errQ := mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithConsistencyLevel(entity.ClStrong).WithPartitions([]string{parName}).WithOutputFields([]string{common.QueryCountFieldName}))
common.CheckErr(t, errQ, true) common.CheckErr(t, errQ, true)
count, _ := res.GetColumn(common.QueryCountFieldName).Get(0) count, _ := res.GetColumn(common.QueryCountFieldName).Get(0)

View File

@ -23,7 +23,7 @@ func TestQueryDefault(t *testing.T) {
// create and insert // create and insert
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
_, insertRes := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) _, insertRes := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
// flush -> index -> load // flush -> index -> load
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -44,7 +44,7 @@ func TestQueryVarcharPkDefault(t *testing.T) {
// create and insert // create and insert
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption())
_, insertRes := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) _, insertRes := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
// flush -> index -> load // flush -> index -> load
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
@ -105,8 +105,8 @@ func TestQueryPartition(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
// insert [0, 3000) into default, insert [3000, 6000) into parName // insert [0, 3000) into default, insert [3000, 6000) into parName
_, i1Res := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) _, i1Res := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
_, i2Res := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb)) _, i2Res := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb))
// flush -> index -> load // flush -> index -> load
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
@ -173,7 +173,7 @@ func TestQueryOutputFields(t *testing.T) {
for _, enableDynamic := range [2]bool{true, false} { for _, enableDynamic := range [2]bool{true, false} {
// create -> insert -> flush -> index -> load // create -> insert -> flush -> index -> load
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(enableDynamic)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(enableDynamic))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -448,7 +448,7 @@ func TestQueryJsonDynamicExpr(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON),
hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -481,7 +481,7 @@ func TestQueryInvalidExpr(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON),
hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 100), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(100))
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -498,7 +498,7 @@ func TestQueryCountJsonDynamicExpr(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields),
hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -570,7 +570,7 @@ func TestQueryArrayFieldExpr(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields),
hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -617,7 +617,7 @@ func TestQueryOutputInvalidOutputFieldCount(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec),
hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(false)) hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(false))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))

View File

@ -24,7 +24,7 @@ func TestSearchDefault(t *testing.T) {
// create -> insert -> flush -> index -> load // create -> insert -> flush -> index -> load
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -44,7 +44,7 @@ func TestSearchDefaultGrowing(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
// search // search
vectors := hp.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeBinaryVector) vectors := hp.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeBinaryVector)
@ -190,7 +190,7 @@ func TestSearchEmptyOutputFields(t *testing.T) {
for _, dynamic := range []bool{true, false} { for _, dynamic := range []bool{true, false} {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(dynamic)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(dynamic))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 100), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(100))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -220,7 +220,7 @@ func TestSearchNotExistOutputFields(t *testing.T) {
for _, enableDynamic := range []bool{false, true} { for _, enableDynamic := range []bool{false, true} {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(enableDynamic)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(enableDynamic))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -262,7 +262,7 @@ func TestSearchOutputAllFields(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -290,7 +290,7 @@ func TestSearchOutputBinaryPk(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -316,7 +316,7 @@ func TestSearchOutputSparse(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -342,7 +342,7 @@ func TestSearchInvalidVectorField(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 500), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(500))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -384,7 +384,7 @@ func TestSearchInvalidVectors(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64MultiVec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64MultiVec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 500), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(500))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -460,7 +460,7 @@ func TestSearchNotMatchMetricType(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 500), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(500))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema). prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).
TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewHNSWIndex(entity.COSINE, 8, 200)})) TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewHNSWIndex(entity.COSINE, 8, 200)}))
@ -477,7 +477,7 @@ func TestSearchInvalidTopK(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 500), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(500))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -495,7 +495,7 @@ func TestSearchInvalidOffset(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 500), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(500))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -519,7 +519,7 @@ func TestSearchEfHnsw(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 500), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(500))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema). prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).
TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewHNSWIndex(entity.COSINE, 8, 200)})) TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewHNSWIndex(entity.COSINE, 8, 200)}))
@ -542,7 +542,7 @@ func TestSearchInvalidScannReorderK(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 500), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(500))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{ prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{
common.DefaultFloatVecFieldName: index.NewSCANNIndex(entity.COSINE, 16, true), common.DefaultFloatVecFieldName: index.NewSCANNIndex(entity.COSINE, 16, true),
@ -588,7 +588,7 @@ func TestSearchExpr(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -620,7 +620,7 @@ func TestSearchInvalidExpr(t *testing.T) {
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -665,7 +665,7 @@ func TestSearchJsonFieldExpr(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(dynamicField)) TWithEnableDynamicField(dynamicField))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -689,7 +689,7 @@ func TestSearchDynamicFieldExpr(t *testing.T) {
// create collection // create collection
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(true)) TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -751,7 +751,7 @@ func TestSearchArrayFieldExpr(t *testing.T) {
// create collection // create collection
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecArray), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecArray), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(true)) TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -802,7 +802,7 @@ func TestSearchNotExistedExpr(t *testing.T) {
for _, isDynamic := range [2]bool{true, false} { for _, isDynamic := range [2]bool{true, false} {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(isDynamic)) TWithEnableDynamicField(isDynamic))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -828,7 +828,7 @@ func TestSearchMultiVectors(t *testing.T) {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64MultiVec), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64MultiVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(true)) TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb*2), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(common.DefaultNb*2))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
flatIndex := index.NewFlatIndex(entity.L2) flatIndex := index.NewFlatIndex(entity.L2)
binIndex := index.NewGenericIndex(common.DefaultBinaryVecFieldName, map[string]string{"nlist": "64", index.MetricTypeKey: "JACCARD", index.IndexTypeKey: "BIN_IVF_FLAT"}) binIndex := index.NewGenericIndex(common.DefaultBinaryVecFieldName, map[string]string{"nlist": "64", index.MetricTypeKey: "JACCARD", index.IndexTypeKey: "BIN_IVF_FLAT"})
@ -895,7 +895,7 @@ func TestSearchSparseVector(t *testing.T) {
for _, idx := range []index.Index{idxInverted, idxWand} { for _, idx := range []index.Index{idxInverted, idxWand} {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(true)) TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb*2), hp.TNewDataOption().TWithSparseMaxLen(128)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithSparseMaxLen(128).TWithNb(common.DefaultNb*2))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultSparseVecFieldName: idx})) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultSparseVecFieldName: idx}))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -929,7 +929,7 @@ func TestSearchInvalidSparseVector(t *testing.T) {
for _, idx := range []index.Index{idxInverted, idxWand} { for _, idx := range []index.Index{idxInverted, idxWand} {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(true)) TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithSparseMaxLen(128)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithSparseMaxLen(128))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultSparseVecFieldName: idx})) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultSparseVecFieldName: idx}))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -964,7 +964,7 @@ func TestSearchSparseVectorPagination(t *testing.T) {
for _, idx := range []index.Index{idxInverted, idxWand} { for _, idx := range []index.Index{idxInverted, idxWand} {
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption(). prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().
TWithEnableDynamicField(true)) TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithSparseMaxLen(128)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithSparseMaxLen(128))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultSparseVecFieldName: idx})) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultSparseVecFieldName: idx}))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -1002,7 +1002,7 @@ func TestRangeSearchSparseVector(t *testing.T) {
TWithEnableDynamicField(true)) TWithEnableDynamicField(true))
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithSparseMaxLen(128)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithSparseMaxLen(128))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
// TODO range search // TODO range search

View File

@ -7,10 +7,12 @@ import (
"time" "time"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"go.uber.org/zap"
"github.com/milvus-io/milvus/client/v2" "github.com/milvus-io/milvus/client/v2"
"github.com/milvus-io/milvus/client/v2/column" "github.com/milvus-io/milvus/client/v2/column"
"github.com/milvus-io/milvus/client/v2/entity" "github.com/milvus-io/milvus/client/v2/entity"
"github.com/milvus-io/milvus/pkg/log"
"github.com/milvus-io/milvus/tests/go_client/common" "github.com/milvus-io/milvus/tests/go_client/common"
hp "github.com/milvus-io/milvus/tests/go_client/testcases/helper" hp "github.com/milvus-io/milvus/tests/go_client/testcases/helper"
) )
@ -31,7 +33,7 @@ func TestUpsertAllFields(t *testing.T) {
// create -> insert [0, 3000) -> flush -> index -> load // create -> insert [0, 3000) -> flush -> index -> load
// create -> insert -> flush -> index -> load // create -> insert -> flush -> index -> load
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 0), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -100,7 +102,7 @@ func TestUpsertSparse(t *testing.T) {
// create -> insert [0, 3000) -> flush -> index -> load // create -> insert [0, 3000) -> flush -> index -> load
// create -> insert -> flush -> index -> load // create -> insert -> flush -> index -> load
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 0), hp.TNewDataOption().TWithSparseMaxLen(128)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithSparseMaxLen(128).TWithNb(0))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
upsertNb := 200 upsertNb := 200
@ -164,7 +166,7 @@ func TestUpsertVarcharPk(t *testing.T) {
// create -> insert [0, 3000) -> flush -> index -> load // create -> insert [0, 3000) -> flush -> index -> load
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -216,8 +218,8 @@ func TestUpsertMultiPartitions(t *testing.T) {
common.CheckErr(t, err, true) common.CheckErr(t, err, true)
// insert [0, nb) into default, insert [nb, nb*2) into new // insert [0, nb) into default, insert [nb, nb*2) into new
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb)) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb))
prepare.FlushData(ctx, t, mc, schema.CollectionName) prepare.FlushData(ctx, t, mc, schema.CollectionName)
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -248,7 +250,7 @@ func TestUpsertSamePksManyTimes(t *testing.T) {
// create and insert // create and insert
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
var _columns []column.Column var _columns []column.Column
upsertNb := 10 upsertNb := 10
@ -284,19 +286,49 @@ func TestUpsertAutoID(t *testing.T) {
*/ */
ctx := hp.CreateContext(t, time.Second*common.DefaultTimeout) ctx := hp.CreateContext(t, time.Second*common.DefaultTimeout)
mc := createDefaultMilvusClient(ctx, t) mc := createDefaultMilvusClient(ctx, t)
nb := 100
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption().TWithAutoID(true), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption().TWithAutoID(true), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, 100), hp.TNewDataOption()) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
_, insertRes := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption().TWithNb(nb))
// upsert without pks // upsert autoID collection with existed pks -> actually delete passed pks and auto generate new pks ? So weired
vecColumn := hp.GenColumnData(100, entity.FieldTypeFloatVector, *hp.TNewDataOption()) vecColumn := hp.GenColumnData(nb, entity.FieldTypeFloatVector, *hp.TNewDataOption())
_, err := mc.Upsert(ctx, client.NewColumnBasedInsertOption(schema.CollectionName).WithColumns(vecColumn)) upsertRes, err := mc.Upsert(ctx, client.NewColumnBasedInsertOption(schema.CollectionName).WithColumns(insertRes.IDs, vecColumn))
common.CheckErr(t, err, false, "upsert can not assign primary field data when auto id enabled") common.CheckErr(t, err, true)
log.Debug("upsertRes", zap.Any("len", upsertRes.IDs.(*column.ColumnInt64).Data()))
// upsert with pks // insertRes pks were deleted
expr := fmt.Sprintf("%s <= %d", common.DefaultInt64FieldName, insertRes.IDs.(*column.ColumnInt64).Data()[nb-1])
log.Debug("expr", zap.String("expr", expr))
resSet, err := mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithConsistencyLevel(entity.ClStrong).WithOutputFields([]string{common.DefaultFloatVecFieldName}).WithFilter(expr))
common.CheckErr(t, err, true)
require.EqualValues(t, 0, resSet.ResultCount)
exprUpsert := fmt.Sprintf("%s <= %d", common.DefaultInt64FieldName, upsertRes.IDs.(*column.ColumnInt64).Data()[nb-1])
log.Debug("expr", zap.String("expr", expr))
resSet1, err := mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithConsistencyLevel(entity.ClStrong).WithOutputFields([]string{common.DefaultFloatVecFieldName}).WithFilter(exprUpsert))
common.CheckErr(t, err, true)
common.EqualColumn(t, vecColumn, resSet1.GetColumn(common.DefaultFloatVecFieldName))
// upsert with not existing pks -> actually auto generate id ?? so weired
pkColumn := hp.GenColumnData(100, entity.FieldTypeInt64, *hp.TNewDataOption()) pkColumn := hp.GenColumnData(100, entity.FieldTypeInt64, *hp.TNewDataOption())
_, err1 := mc.Upsert(ctx, client.NewColumnBasedInsertOption(schema.CollectionName).WithColumns(pkColumn, vecColumn)) upsertRes, err1 := mc.Upsert(ctx, client.NewColumnBasedInsertOption(schema.CollectionName).WithColumns(pkColumn, vecColumn))
common.CheckErr(t, err1, false, "upsert can not assign primary field data when auto id enabled") common.CheckErr(t, err1, true)
require.EqualValues(t, nb, upsertRes.UpsertCount)
// query and verify upsert result
upsertPks := upsertRes.IDs.(*column.ColumnInt64).Data()
resSet, err = mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithConsistencyLevel(entity.ClStrong).WithOutputFields([]string{common.DefaultFloatVecFieldName}).
WithFilter(fmt.Sprintf("%d <= %s", upsertPks[0], common.DefaultInt64FieldName)))
common.CheckErr(t, err, true)
common.EqualColumn(t, vecColumn, resSet.GetColumn(common.DefaultFloatVecFieldName))
// upsert without pks -> error
vecColumn = hp.GenColumnData(nb, entity.FieldTypeFloatVector, *hp.TNewDataOption())
_, err = mc.Upsert(ctx, client.NewColumnBasedInsertOption(schema.CollectionName).WithColumns(vecColumn))
common.CheckErr(t, err, false, "has no corresponding fieldData pass in: invalid parameter")
} }
// test upsert with invalid collection / partition name // test upsert with invalid collection / partition name
@ -379,7 +411,7 @@ func TestUpsertDynamicField(t *testing.T) {
// create -> insert [0, 3000) -> flush -> index -> load // create -> insert [0, 3000) -> flush -> index -> load
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true)) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema)) prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName)) prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
@ -422,7 +454,7 @@ func TestUpsertWithoutLoading(t *testing.T) {
// create and insert // create and insert
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption()) prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecJSON), hp.TNewFieldsOption(), hp.TNewSchemaOption())
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption()) prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema), hp.TNewDataOption())
// upsert // upsert
upsertNb := 10 upsertNb := 10