Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Create TRIE scalar index on non-varchar field but does not return an error #694

Closed
1 task done
ThreadDao opened this issue Apr 3, 2024 · 2 comments
Closed
1 task done

Comments

@ThreadDao
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

  • image: master-20240402-bd853be8c-amd64
  • go-sdk: master

case:

// Trie scalar index only supported on varchar
func TestCreateTrieScalarIndexUnsupportedDataType(t *testing.T) {
	ctx := createContext(t, time.Second*common.DefaultTimeout*2)
	// connect
	mc := createMilvusClient(ctx, t)

	// create -> insert [0, 3000) -> flush -> index -> load
	cp := CollectionParams{CollectionFieldsType: AllFields, AutoID: false, EnableDynamicField: false,
		ShardsNum: common.DefaultShards, Dim: common.DefaultDim}

	dp := DataParams{DoInsert: true, CollectionFieldsType: AllFields, start: 0, nb: common.DefaultNb,
		dim: common.DefaultDim, EnableDynamicField: false}

	// index params
	ips := []IndexParams{{BuildIndex: false}}
	lp := LoadParams{DoLoad: false}
	collName := prepareCollection(ctx, t, mc, cp, WithDataParams(dp), WithIndexParams(ips), WithLoadParams(lp),
		WithCreateOption(client.WithConsistencyLevel(entity.ClStrong)))

	// create Trie scalar index on varchar field
	coll, _ := mc.DescribeCollection(ctx, collName)
	idx := entity.NewScalarIndexWithType(entity.Trie)
	for _, field := range coll.Schema.Fields {
		if supportScalarIndexFieldType(field.DataType) {
			if field.DataType == entity.FieldTypeVarChar {
				err := mc.CreateIndex(ctx, collName, field.Name, idx, false, client.WithIndexName(field.Name))
				common.CheckErr(t, err, true)

				// describe index
				indexes, _ := mc.DescribeIndex(ctx, collName, field.Name)
				expIndex := entity.NewGenericIndex(field.Name, entity.Trie, idx.Params())
				common.CheckIndexResult(t, indexes, expIndex)
			} else {
				err := mc.CreateIndex(ctx, collName, field.Name, idx, false, client.WithIndexName(field.Name))
				common.CheckErr(t, err, false, "TRIE are only supported on varchar field")
			}
		}
	}
}

Expected Behavior

error

Steps To Reproduce

No response

Environment

No response

Anything else?

No response

@ThreadDao
Copy link
Contributor Author

The same as SORT index: "STL_SORT are only supported on numeric field"

// Sort scalar index only supported on numeric field
func TestCreateSortScalarIndexUnsupportedDataType(t *testing.T) {
	ctx := createContext(t, time.Second*common.DefaultTimeout*2)
	// connect
	mc := createMilvusClient(ctx, t)

	// create -> insert [0, 3000) -> flush -> index -> load
	cp := CollectionParams{CollectionFieldsType: AllFields, AutoID: false, EnableDynamicField: false,
		ShardsNum: common.DefaultShards, Dim: common.DefaultDim}

	dp := DataParams{DoInsert: true, CollectionFieldsType: AllFields, start: 0, nb: common.DefaultNb,
		dim: common.DefaultDim, EnableDynamicField: false}

	// index params
	ips := []IndexParams{{BuildIndex: false}}
	lp := LoadParams{DoLoad: false}
	collName := prepareCollection(ctx, t, mc, cp, WithDataParams(dp), WithIndexParams(ips), WithLoadParams(lp),
		WithCreateOption(client.WithConsistencyLevel(entity.ClStrong)))

	// create Trie scalar index on varchar field
	coll, _ := mc.DescribeCollection(ctx, collName)
	idx := entity.NewScalarIndexWithType(entity.Sorted)
	for _, field := range coll.Schema.Fields {
		if supportScalarIndexFieldType(field.DataType) {
			if field.DataType == entity.FieldTypeVarChar {
				err := mc.CreateIndex(ctx, collName, field.Name, idx, false, client.WithIndexName(field.Name))
				common.CheckErr(t, err, false, "STL_SORT are only supported on numeric field")
			} else {
				err := mc.CreateIndex(ctx, collName, field.Name, idx, false, client.WithIndexName(field.Name))
				common.CheckErr(t, err, true)
				// describe index
				indexes, _ := mc.DescribeIndex(ctx, collName, field.Name)
				expIndex := entity.NewGenericIndex(field.Name, "", idx.Params())
				common.CheckIndexResult(t, indexes, expIndex)
			}
		}
	}
}

congqixia added a commit to congqixia/milvus-sdk-go that referenced this issue Apr 3, 2024
Related to milvus-io#694 milvus-io#695

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
congqixia added a commit to congqixia/milvus-sdk-go that referenced this issue Apr 8, 2024
Related to milvus-io#694 milvus-io#695

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
sre-ci-robot pushed a commit that referenced this issue Apr 8, 2024
Related to #694 #695

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
@ThreadDao
Copy link
Contributor Author

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant