mirror of https://github.com/milvus-io/milvus.git
test: add test cases for gosdk v2 index (#34431)
issue: #33419 - Add test cases for gosdk v2 index - Add sparse index for go client Signed-off-by: ThreadDao <yufen.zong@zilliz.com>pull/34443/head
parent
d65b6895d7
commit
67747245f4
|
@ -51,6 +51,10 @@ const (
|
|||
DISKANN IndexType = "DISKANN"
|
||||
SCANN IndexType = "SCANN"
|
||||
|
||||
// Sparse
|
||||
SparseInverted IndexType = "SPARSE_INVERTED_INDEX"
|
||||
SparseWAND IndexType = "SPARSE_WAND"
|
||||
|
||||
GPUIvfFlat IndexType = "GPU_IVF_FLAT"
|
||||
GPUIvfPQ IndexType = "GPU_IVF_PQ"
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ func (idx ivfSQ8Index) Params() map[string]string {
|
|||
}
|
||||
|
||||
func NewIvfSQ8Index(metricType MetricType, nlist int) Index {
|
||||
return ivfPQIndex{
|
||||
return ivfSQ8Index{
|
||||
baseIndex: baseIndex{
|
||||
metricType: metricType,
|
||||
indexType: IvfSQ8,
|
||||
|
@ -122,7 +122,7 @@ type binIvfFlat struct {
|
|||
func (idx binIvfFlat) Params() map[string]string {
|
||||
return map[string]string{
|
||||
MetricTypeKey: string(idx.metricType),
|
||||
IndexTypeKey: string(IvfSQ8),
|
||||
IndexTypeKey: string(BinIvfFlat),
|
||||
ivfNlistKey: strconv.Itoa(idx.nlist),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ func (idx scannIndex) Params() map[string]string {
|
|||
}
|
||||
|
||||
func NewSCANNIndex(metricType MetricType, nlist int, withRawData bool) Index {
|
||||
return ivfFlatIndex{
|
||||
return scannIndex{
|
||||
baseIndex: baseIndex{
|
||||
metricType: metricType,
|
||||
indexType: SCANN,
|
||||
},
|
||||
|
||||
nlist: nlist,
|
||||
withRawData: withRawData,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
package index
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
dropRatio = `drop_ratio_build`
|
||||
)
|
||||
|
||||
var _ Index = sparseInvertedIndex{}
|
||||
|
||||
// IndexSparseInverted index type for SPARSE_INVERTED_INDEX
|
||||
type sparseInvertedIndex struct {
|
||||
baseIndex
|
||||
dropRatio float64
|
||||
}
|
||||
|
||||
func (idx sparseInvertedIndex) Params() map[string]string {
|
||||
return map[string]string{
|
||||
MetricTypeKey: string(idx.metricType),
|
||||
IndexTypeKey: string(SparseInverted),
|
||||
dropRatio: fmt.Sprintf("%v", idx.dropRatio),
|
||||
}
|
||||
}
|
||||
|
||||
func NewSparseInvertedIndex(metricType MetricType, dropRatio float64) Index {
|
||||
return sparseInvertedIndex {
|
||||
baseIndex: baseIndex{
|
||||
metricType: metricType,
|
||||
indexType: SparseInverted,
|
||||
},
|
||||
|
||||
dropRatio: dropRatio,
|
||||
}
|
||||
}
|
||||
|
||||
var _ Index = sparseWANDIndex{}
|
||||
type sparseWANDIndex struct {
|
||||
baseIndex
|
||||
dropRatio float64
|
||||
}
|
||||
|
||||
func (idx sparseWANDIndex) Params() map[string]string {
|
||||
return map[string]string{
|
||||
MetricTypeKey: string(idx.metricType),
|
||||
IndexTypeKey: string(SparseWAND),
|
||||
dropRatio: fmt.Sprintf("%v", idx.dropRatio),
|
||||
}
|
||||
}
|
||||
|
||||
// IndexSparseWAND index type for SPARSE_WAND, weak-and
|
||||
func NewSparseWANDIndex(metricType MetricType, dropRatio float64) Index {
|
||||
return sparseWANDIndex {
|
||||
baseIndex: baseIndex{
|
||||
metricType: metricType,
|
||||
indexType: SparseWAND,
|
||||
},
|
||||
|
||||
dropRatio: dropRatio,
|
||||
}
|
||||
}
|
||||
|
|
@ -180,8 +180,8 @@ func (mc *MilvusClient) ListIndexes(ctx context.Context, option clientv2.ListInd
|
|||
|
||||
// DescribeIndex Describe Index
|
||||
func (mc *MilvusClient) DescribeIndex(ctx context.Context, option clientv2.DescribeIndexOption, callOptions ...grpc.CallOption) (index.Index, error) {
|
||||
index, err := mc.mClient.DescribeIndex(ctx, option, callOptions...)
|
||||
return index, err
|
||||
idx, err := mc.mClient.DescribeIndex(ctx, option, callOptions...)
|
||||
return idx, err
|
||||
}
|
||||
|
||||
// DropIndex Drop Index
|
||||
|
|
|
@ -33,7 +33,7 @@ func CheckErr(t *testing.T, actualErr error, expErrNil bool, expErrorMsg ...stri
|
|||
}
|
||||
}
|
||||
if !contains {
|
||||
t.Fatalf("CheckErr failed, actualErr doesn contains any expErrorMsg, please check test cases!")
|
||||
t.Fatalf("CheckErr failed, actualErr doesn't contains any expErrorMsg, actual msg:%s", actualErr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,4 +175,4 @@ func CheckQueryResult(t *testing.T, expColumns []column.Column, actualColumns []
|
|||
log.Error("CheckQueryResult actualColumns no column", zap.String("name", expColumn.Name()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ go 1.21
|
|||
toolchain go1.21.10
|
||||
|
||||
require (
|
||||
github.com/milvus-io/milvus/client/v2 v2.0.0-20240703023208-fb61344dc9b5
|
||||
github.com/milvus-io/milvus/client/v2 v2.0.0-20240704083609-fcafdb6d5f68
|
||||
github.com/milvus-io/milvus/pkg v0.0.2-0.20240317152703-17b4938985f3
|
||||
github.com/quasilyte/go-ruleguard/dsl v0.3.22
|
||||
github.com/stretchr/testify v1.9.0
|
||||
|
@ -14,7 +14,7 @@ require (
|
|||
google.golang.org/grpc v1.64.0
|
||||
)
|
||||
|
||||
// replace github.com/milvus-io/milvus/client/v2 v2.0.0-20240703023208-fb61344dc9b5 => ../../../milvus/client
|
||||
replace github.com/milvus-io/milvus/client/v2 v2.0.0-20240704083609-fcafdb6d5f68 => ../../../milvus/client
|
||||
|
||||
require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
|
|
|
@ -403,8 +403,6 @@ 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/milvus-io/milvus-proto/go-api/v2 v2.4.3 h1:KUSaWVePVlHMIluAXf2qmNffI1CMlGFLLiP+4iy9014=
|
||||
github.com/milvus-io/milvus-proto/go-api/v2 v2.4.3/go.mod h1:1OIl0v5PQeNxIJhCvY+K55CBUOYDZevw9g9380u1Wek=
|
||||
github.com/milvus-io/milvus/client/v2 v2.0.0-20240703023208-fb61344dc9b5 h1:jsMriUhlv82KS34VV6y/SDpeL+MEWcO6nR4Ur1diEf8=
|
||||
github.com/milvus-io/milvus/client/v2 v2.0.0-20240703023208-fb61344dc9b5/go.mod h1:13uL9ukc9KRK5ZtWqWwaORWlRccZLIysZzT6KUlOx+A=
|
||||
github.com/milvus-io/milvus/pkg v0.0.2-0.20240317152703-17b4938985f3 h1:ZBpRWhBa7FTFxW4YYVv9AUESoW1Xyb3KNXTzTqfkZmw=
|
||||
github.com/milvus-io/milvus/pkg v0.0.2-0.20240317152703-17b4938985f3/go.mod h1:jQ2BUZny1COsgv1Qbcv8dmbppW+V9J/c4YQZNb3EOm8=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestDelete(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load collection
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// delete with expr
|
||||
|
@ -64,7 +64,7 @@ func TestDeleteVarcharPks(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load collection
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// delete varchar with pk
|
||||
|
@ -101,7 +101,7 @@ func TestDeleteEmptyCollection(t *testing.T) {
|
|||
require.Equal(t, int64(1), delRes.DeleteCount)
|
||||
|
||||
// delete complex expr from empty collection
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
comExpr := fmt.Sprintf("%s < 10", common.DefaultInt64FieldName)
|
||||
|
@ -154,7 +154,7 @@ func TestDeleteComplexExprWithoutLoad(t *testing.T) {
|
|||
common.CheckErr(t, errDelete2, false, "collection not loaded")
|
||||
|
||||
// index and load collection
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
res, err := mc.Query(ctx, client.NewQueryOption(schema.CollectionName).WithFilter(fmt.Sprintf("%s >= 0 ", common.DefaultInt64FieldName)).
|
||||
|
@ -205,7 +205,7 @@ func TestDeleteVarcharEmptyIds(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load collection
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
exprQuery := "varchar != '' "
|
||||
|
@ -274,7 +274,7 @@ func TestDeleteWithIds(t *testing.T) {
|
|||
_, err = mc.Insert(ctx, insertOpt)
|
||||
common.CheckErr(t, err, true)
|
||||
// index and load
|
||||
hp.CollPrepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
hp.CollPrepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
hp.CollPrepare.Load(ctx, t, mc, hp.NewLoadParams(collName))
|
||||
|
||||
// delete with non-pk fields ids
|
||||
|
@ -310,7 +310,7 @@ func TestDeleteDefaultPartitionName(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// delete with default params, actually delete from all partitions
|
||||
|
@ -348,7 +348,7 @@ func TestDeleteEmptyPartitionName(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// delete with default params, actually delete from all partitions
|
||||
|
@ -386,7 +386,7 @@ func TestDeletePartitionName(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// delete with default params, actually delete from all partitions
|
||||
|
@ -489,7 +489,7 @@ func TestDeleteComplexExpr(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
log.Debug("TestDeleteComplexExpr", zap.Any("expr", exprLimit.expr))
|
||||
|
@ -518,7 +518,7 @@ func TestDeleteInvalidExpr(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
for _, _invalidExpr := range common.InvalidExpressions {
|
||||
|
@ -541,7 +541,7 @@ func TestDeleteDuplicatedPks(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
||||
// index and load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// delete
|
||||
|
|
|
@ -249,7 +249,7 @@ func GenDefaultJSONData(nb int, option GenDataOption) [][]byte {
|
|||
return jsonValues
|
||||
}
|
||||
|
||||
// GenColumnData GenColumnDataOption
|
||||
// GenColumnData GenColumnDataOption except dynamic column
|
||||
func GenColumnData(nb int, fieldType entity.FieldType, option GenDataOption) column.Column {
|
||||
dim := option.dim
|
||||
sparseMaxLen := option.sparseMaxLen
|
||||
|
|
|
@ -2,6 +2,7 @@ package helper
|
|||
|
||||
import (
|
||||
"context"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -141,6 +142,7 @@ func (chainTask *CollectionPrepare) InsertData(ctx context.Context, t *testing.T
|
|||
}
|
||||
insertRes, err := mc.Insert(ctx, insertOpt)
|
||||
common.CheckErr(t, err, true)
|
||||
require.Equal(t, option.nb, insertRes.IDs.Len())
|
||||
return chainTask, insertRes
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package helper
|
|||
import (
|
||||
"github.com/milvus-io/milvus/client/v2/entity"
|
||||
"github.com/milvus-io/milvus/client/v2/index"
|
||||
"github.com/milvus-io/milvus/tests/go_client/common"
|
||||
)
|
||||
|
||||
func GetDefaultVectorIndex(fieldType entity.FieldType) index.Index {
|
||||
|
@ -11,13 +10,11 @@ func GetDefaultVectorIndex(fieldType entity.FieldType) index.Index {
|
|||
case entity.FieldTypeFloatVector, entity.FieldTypeFloat16Vector, entity.FieldTypeBFloat16Vector:
|
||||
return index.NewHNSWIndex(entity.COSINE, 8, 200)
|
||||
case entity.FieldTypeBinaryVector:
|
||||
return index.NewGenericIndex(common.DefaultBinaryVecFieldName, map[string]string{"nlist": "64", index.MetricTypeKey: "JACCARD", index.IndexTypeKey: "BIN_IVF_FLAT"})
|
||||
// return binary index
|
||||
return index.NewBinIvfFlatIndex(entity.JACCARD, 64)
|
||||
case entity.FieldTypeSparseVector:
|
||||
return index.NewGenericIndex(common.DefaultSparseVecFieldName, map[string]string{"drop_ratio_build": "0.1", index.MetricTypeKey: "IP", index.IndexTypeKey: "SPARSE_INVERTED_INDEX"})
|
||||
return index.NewSparseInvertedIndex(entity.IP, 0.1)
|
||||
default:
|
||||
return nil
|
||||
// return auto index
|
||||
return index.NewAutoIndex(entity.COSINE)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +23,7 @@ type IndexParams struct {
|
|||
FieldIndexMap map[string]index.Index
|
||||
}
|
||||
|
||||
func NewIndexParams(schema *entity.Schema) *IndexParams {
|
||||
func TNewIndexParams(schema *entity.Schema) *IndexParams {
|
||||
return &IndexParams{
|
||||
Schema: schema,
|
||||
}
|
||||
|
@ -36,3 +33,65 @@ func (opt *IndexParams) TWithFieldIndex(mFieldIndex map[string]index.Index) *Ind
|
|||
opt.FieldIndexMap = mFieldIndex
|
||||
return opt
|
||||
}
|
||||
|
||||
/*
|
||||
utils func
|
||||
*/
|
||||
var SupportFloatMetricType = []entity.MetricType{
|
||||
entity.L2,
|
||||
entity.IP,
|
||||
entity.COSINE,
|
||||
}
|
||||
|
||||
var SupportBinFlatMetricType = []entity.MetricType{
|
||||
entity.JACCARD,
|
||||
entity.HAMMING,
|
||||
entity.SUBSTRUCTURE,
|
||||
entity.SUPERSTRUCTURE,
|
||||
}
|
||||
|
||||
var SupportBinIvfFlatMetricType = []entity.MetricType{
|
||||
entity.JACCARD,
|
||||
entity.HAMMING,
|
||||
}
|
||||
|
||||
var UnsupportedSparseVecMetricsType = []entity.MetricType{
|
||||
entity.L2,
|
||||
entity.COSINE,
|
||||
entity.JACCARD,
|
||||
entity.HAMMING,
|
||||
entity.SUBSTRUCTURE,
|
||||
entity.SUPERSTRUCTURE,
|
||||
}
|
||||
|
||||
|
||||
// GenAllFloatIndex gen all float vector index
|
||||
func GenAllFloatIndex(metricType entity.MetricType) []index.Index {
|
||||
nlist := 128
|
||||
var allFloatIndex []index.Index
|
||||
|
||||
idxFlat := index.NewFlatIndex(metricType)
|
||||
idxIvfFlat := index.NewIvfFlatIndex(metricType, nlist)
|
||||
idxIvfSq8 := index.NewIvfSQ8Index(metricType, nlist)
|
||||
idxIvfPq := index.NewIvfPQIndex(metricType, nlist, 16, 8)
|
||||
idxHnsw := index.NewHNSWIndex(metricType, 8, 96)
|
||||
idxScann := index.NewSCANNIndex(metricType, 16, true)
|
||||
idxDiskAnn := index.NewDiskANNIndex(metricType)
|
||||
allFloatIndex = append(allFloatIndex, idxFlat, idxIvfFlat, idxIvfSq8, idxIvfPq, idxHnsw, idxScann, idxDiskAnn)
|
||||
|
||||
return allFloatIndex
|
||||
}
|
||||
|
||||
func SupportScalarIndexFieldType(field entity.FieldType) bool {
|
||||
vectorFieldTypes := []entity.FieldType{
|
||||
entity.FieldTypeBinaryVector, entity.FieldTypeFloatVector,
|
||||
entity.FieldTypeFloat16Vector, entity.FieldTypeBFloat16Vector,
|
||||
entity.FieldTypeSparseVector, entity.FieldTypeJSON,
|
||||
}
|
||||
for _, vectorFieldType := range vectorFieldTypes {
|
||||
if field == vectorFieldType {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -27,7 +27,7 @@ func TestQueryDefault(t *testing.T) {
|
|||
|
||||
// flush -> index -> load
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query
|
||||
|
@ -47,7 +47,7 @@ func TestQueryVarcharPkDefault(t *testing.T) {
|
|||
_, insertRes := prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
|
||||
// flush -> index -> load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query
|
||||
|
@ -69,7 +69,7 @@ func TestQueryNotExistName(t *testing.T) {
|
|||
|
||||
// create -> index -> load
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query with not existed partition
|
||||
|
@ -110,7 +110,7 @@ func TestQueryPartition(t *testing.T) {
|
|||
|
||||
// flush -> index -> load
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
expr := fmt.Sprintf("%s >= %d", common.DefaultInt64FieldName, 0)
|
||||
|
@ -175,7 +175,7 @@ func TestQueryOutputFields(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
expr := fmt.Sprintf("%s < %d", common.DefaultInt64FieldName, 10)
|
||||
|
@ -245,7 +245,7 @@ func TestQueryOutputAllFieldsColumn(t *testing.T) {
|
|||
// create collection
|
||||
for _, isDynamic := range [2]bool{true, false} {
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(isDynamic))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// insert
|
||||
|
@ -309,7 +309,7 @@ func TestQueryOutputAllFieldsRows(t *testing.T) {
|
|||
require.Equal(t, int64(common.DefaultNb), ids.InsertCount)
|
||||
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query output all fields -> output all fields, includes vector and $meta field
|
||||
|
@ -329,7 +329,7 @@ func TestQueryOutputBinaryAndVarchar(t *testing.T) {
|
|||
mc := createDefaultMilvusClient(ctx, t)
|
||||
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(true))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// insert
|
||||
|
@ -366,7 +366,7 @@ func TestQueryOutputSparse(t *testing.T) {
|
|||
mc := createDefaultMilvusClient(ctx, t)
|
||||
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// insert
|
||||
|
@ -401,7 +401,7 @@ func TestQueryArrayDifferentLenBetweenRows(t *testing.T) {
|
|||
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VecAllScalar),
|
||||
hp.TNewFieldsOption().TWithMaxCapacity(common.TestCapacity*2), hp.TNewSchemaOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// insert 2 batch with array capacity 100 and 200
|
||||
|
@ -449,7 +449,7 @@ func TestQueryJsonDynamicExpr(t *testing.T) {
|
|||
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.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query with different expr and count
|
||||
|
@ -482,7 +482,7 @@ func TestQueryInvalidExpr(t *testing.T) {
|
|||
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, 100), hp.TNewDataOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
for _, _invalidExpr := range common.InvalidExpressions {
|
||||
|
@ -499,7 +499,7 @@ func TestQueryCountJsonDynamicExpr(t *testing.T) {
|
|||
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.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query with different expr and count
|
||||
|
@ -571,7 +571,7 @@ func TestQueryArrayFieldExpr(t *testing.T) {
|
|||
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.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// create collection
|
||||
|
@ -618,7 +618,7 @@ func TestQueryOutputInvalidOutputFieldCount(t *testing.T) {
|
|||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec),
|
||||
hp.TNewFieldsOption(), hp.TNewSchemaOption().TWithEnableDynamicField(false))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// invalid expr
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestSearchDefault(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search
|
||||
|
@ -42,7 +42,7 @@ func TestSearchDefaultGrowing(t *testing.T) {
|
|||
|
||||
// create -> index -> load -> insert
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.VarcharBinary), hp.TNewFieldsOption(), hp.TNewSchemaOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
|
||||
|
@ -88,7 +88,7 @@ func TestSearchEmptyCollection(t *testing.T) {
|
|||
// create -> index -> load
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.AllFields), hp.TNewFieldsOption(),
|
||||
hp.TNewSchemaOption().TWithEnableDynamicField(enableDynamicField))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
type mNameVec struct {
|
||||
|
@ -116,7 +116,7 @@ func TestSearchEmptySparseCollection(t *testing.T) {
|
|||
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(),
|
||||
hp.TNewSchemaOption().TWithEnableDynamicField(true))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search
|
||||
|
@ -152,7 +152,7 @@ func TestSearchPartitions(t *testing.T) {
|
|||
|
||||
// flush -> FLAT index -> load
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewFlatIndex(entity.COSINE)}))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewFlatIndex(entity.COSINE)}))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search with empty partition name []string{""} -> error
|
||||
|
@ -192,7 +192,7 @@ func TestSearchEmptyOutputFields(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
vectors := hp.GenSearchVectors(common.DefaultNq, common.DefaultDim, entity.FieldTypeFloatVector)
|
||||
|
@ -222,7 +222,7 @@ func TestSearchNotExistOutputFields(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search vector output fields not exist, part exist
|
||||
|
@ -264,7 +264,7 @@ func TestSearchOutputAllFields(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
//
|
||||
|
@ -292,7 +292,7 @@ func TestSearchOutputBinaryPk(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
//
|
||||
|
@ -318,7 +318,7 @@ func TestSearchOutputSparse(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
//
|
||||
|
@ -344,7 +344,7 @@ func TestSearchInvalidVectorField(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
type invalidVectorFieldStruct struct {
|
||||
|
@ -386,7 +386,7 @@ func TestSearchInvalidVectors(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
type invalidVectorsStruct struct {
|
||||
|
@ -426,7 +426,7 @@ func TestSearchEmptyInvalidVectors(t *testing.T) {
|
|||
mc := createDefaultMilvusClient(ctx, t)
|
||||
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64Vec), hp.TNewFieldsOption(), hp.TNewSchemaOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
type invalidVectorsStruct struct {
|
||||
|
@ -462,7 +462,7 @@ func TestSearchNotMatchMetricType(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema).
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).
|
||||
TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewHNSWIndex(entity.COSINE, 8, 200)}))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
|
@ -479,7 +479,7 @@ func TestSearchInvalidTopK(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
vectors := hp.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeFloatVector)
|
||||
|
@ -497,7 +497,7 @@ func TestSearchInvalidOffset(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
vectors := hp.GenSearchVectors(1, common.DefaultDim, entity.FieldTypeFloatVector)
|
||||
|
@ -521,7 +521,7 @@ func TestSearchEfHnsw(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema).
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).
|
||||
TWithFieldIndex(map[string]index.Index{common.DefaultFloatVecFieldName: index.NewHNSWIndex(entity.COSINE, 8, 200)}))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
|
@ -544,9 +544,8 @@ func TestSearchInvalidScannReorderK(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema).TWithFieldIndex(map[string]index.Index{
|
||||
common.DefaultFloatVecFieldName: index.NewSCANNIndex(entity.COSINE, 16, true),
|
||||
}))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{
|
||||
common.DefaultFloatVecFieldName: index.NewSCANNIndex(entity.COSINE, 16, true)}))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search with invalid reorder_k < topK
|
||||
|
@ -566,7 +565,7 @@ func TestSearchScannAllMetricsWithRawData(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(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),
|
||||
}))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
@ -590,7 +589,7 @@ func TestSearchExpr(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
type mExprExpected struct {
|
||||
|
@ -622,7 +621,7 @@ func TestSearchInvalidExpr(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search with invalid expr
|
||||
|
@ -667,7 +666,7 @@ func TestSearchJsonFieldExpr(t *testing.T) {
|
|||
TWithEnableDynamicField(dynamicField))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search with jsonField expr key datatype and json data type mismatch
|
||||
|
@ -691,7 +690,7 @@ func TestSearchDynamicFieldExpr(t *testing.T) {
|
|||
TWithEnableDynamicField(true))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
exprs := []string{
|
||||
|
@ -753,7 +752,7 @@ func TestSearchArrayFieldExpr(t *testing.T) {
|
|||
TWithEnableDynamicField(true))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
var capacity int64 = common.TestCapacity
|
||||
|
@ -804,7 +803,7 @@ func TestSearchNotExistedExpr(t *testing.T) {
|
|||
TWithEnableDynamicField(isDynamic))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// search with invalid expr
|
||||
|
@ -832,7 +831,7 @@ func TestSearchMultiVectors(t *testing.T) {
|
|||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
flatIndex := index.NewFlatIndex(entity.L2)
|
||||
binIndex := index.NewGenericIndex(common.DefaultBinaryVecFieldName, map[string]string{"nlist": "64", index.MetricTypeKey: "JACCARD", index.IndexTypeKey: "BIN_IVF_FLAT"})
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema).TWithFieldIndex(map[string]index.Index{
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema).TWithFieldIndex(map[string]index.Index{
|
||||
common.DefaultFloatVecFieldName: flatIndex,
|
||||
common.DefaultFloat16VecFieldName: flatIndex,
|
||||
common.DefaultBFloat16VecFieldName: flatIndex,
|
||||
|
@ -897,7 +896,7 @@ func TestSearchSparseVector(t *testing.T) {
|
|||
TWithEnableDynamicField(true))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb*2), hp.TNewDataOption().TWithSparseMaxLen(128))
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(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))
|
||||
|
||||
// search
|
||||
|
@ -931,7 +930,7 @@ func TestSearchInvalidSparseVector(t *testing.T) {
|
|||
TWithEnableDynamicField(true))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithSparseMaxLen(128))
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(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))
|
||||
|
||||
_, errSearch := mc.Search(ctx, client.NewSearchOption(schema.CollectionName, common.DefaultLimit, []entity.Vector{}).WithConsistencyLevel(entity.ClStrong))
|
||||
|
@ -966,7 +965,7 @@ func TestSearchSparseVectorPagination(t *testing.T) {
|
|||
TWithEnableDynamicField(true))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithSparseMaxLen(128))
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(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))
|
||||
|
||||
// search
|
||||
|
@ -1000,7 +999,7 @@ func TestRangeSearchSparseVector(t *testing.T) {
|
|||
|
||||
prepare, schema := hp.CollPrepare.CreateCollection(ctx, t, mc, hp.NewCreateCollectionParams(hp.Int64VarcharSparseVec), hp.TNewFieldsOption(), hp.TNewSchemaOption().
|
||||
TWithEnableDynamicField(true))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption().TWithSparseMaxLen(128))
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestUpsertAllFields(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
upsertNb := 200
|
||||
|
@ -111,7 +111,7 @@ func TestUpsertSparse(t *testing.T) {
|
|||
common.CheckErr(t, err, true)
|
||||
require.EqualValues(t, upsertNb, upsertRes.UpsertCount)
|
||||
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
expr := fmt.Sprintf("%s < %d", common.DefaultInt64FieldName, upsertNb)
|
||||
|
@ -166,7 +166,7 @@ func TestUpsertVarcharPk(t *testing.T) {
|
|||
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.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
upsertNb := 10
|
||||
|
@ -219,7 +219,7 @@ func TestUpsertMultiPartitions(t *testing.T) {
|
|||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
prepare.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb).TWithPartitionName(parName), hp.TNewDataOption().TWithStart(common.DefaultNb))
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// upsert new partition
|
||||
|
@ -261,7 +261,7 @@ func TestUpsertSamePksManyTimes(t *testing.T) {
|
|||
|
||||
// flush -> index -> load
|
||||
prepare.FlushData(ctx, t, mc, schema.CollectionName)
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query and verify the updated entities
|
||||
|
@ -380,7 +380,7 @@ func TestUpsertDynamicField(t *testing.T) {
|
|||
// 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.InsertData(ctx, t, mc, hp.NewInsertParams(schema, common.DefaultNb), hp.TNewDataOption())
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// verify that dynamic field exists
|
||||
|
@ -432,7 +432,7 @@ func TestUpsertWithoutLoading(t *testing.T) {
|
|||
common.CheckErr(t, err, true)
|
||||
|
||||
// index -> load
|
||||
prepare.CreateIndex(ctx, t, mc, hp.NewIndexParams(schema))
|
||||
prepare.CreateIndex(ctx, t, mc, hp.TNewIndexParams(schema))
|
||||
prepare.Load(ctx, t, mc, hp.NewLoadParams(schema.CollectionName))
|
||||
|
||||
// query and verify
|
||||
|
|
Loading…
Reference in New Issue