Repository: milvus-io/milvus-sdk-go
Pull request #598 (2023-10-16 03:53:18)

Remove `Flush` operation before create index
See also #594 
sync behavior with pymilvus
/kind improvement

sre-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/598#" title="Author self-approved">congqixia</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)~~ [congqixia]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/client/index.go b/client/index.go
index 6f725aa..6b71713 100644
--- a/client/index.go
+++ b/client/index.go
@@ -90,11 +90,6 @@ func (c *GrpcClient) CreateIndex(ctx context.Context, collName string, fieldName
 		return err
 	}
 
-	flushErr := c.Flush(ctx, collName, true)
-	if flushErr != nil {
-		return flushErr
-	}
-
 	idxDef := getIndexDef(opts...)
 
 	req := &milvuspb.CreateIndexRequest{
diff --git a/entity/genidx/genidx.go b/entity/genidx/genidx.go
index 2f997be..b99dad7 100644
--- a/entity/genidx/genidx.go
+++ b/entity/genidx/genidx.go
@@ -710,7 +710,7 @@ func main() {
 			},
 			{
 				IdxName: "SCANN",
-				IdxType: entity.IvfFlat,
+				IdxType: entity.SCANN,
 				ConstructParams: []idxParam{
 					{
 						Name:           "nlist",
diff --git a/entity/indexes_gen.go b/entity/indexes_gen.go
index 0604c5b..e4b84fe 100755
--- a/entity/indexes_gen.go
+++ b/entity/indexes_gen.go
@@ -727,7 +727,7 @@ func NewIndexGPUIvfPQ(metricType MetricType,
 
 var _ Index = &IndexSCANN{}
 
-// IndexSCANN idx type for IVF_FLAT
+// IndexSCANN idx type for SCANN
 type IndexSCANN struct { //auto generated fields
 	nlist int
 	with_raw_data bool
@@ -741,7 +741,7 @@ func(i *IndexSCANN) Name() string {
 
 // IndexType returns IndexType, implementing Index interface
 func(i *IndexSCANN) IndexType() IndexType {
-	return IndexType("IVF_FLAT")
+	return IndexType("SCANN")
 }
 
 // SupportBinary returns whether index type support binary vector
diff --git a/entity/indexes_search_param_gen.go b/entity/indexes_search_param_gen.go
index a5a8148..1a8b6b2 100755
--- a/entity/indexes_search_param_gen.go
+++ b/entity/indexes_search_param_gen.go
@@ -382,7 +382,7 @@ func NewIndexGPUIvfPQSearchParam(
 
 var _ SearchParam = &IndexSCANNSearchParam{}
 
-// IndexSCANNSearchParam search param struct for index type IVF_FLAT
+// IndexSCANNSearchParam search param struct for index type SCANN
 type IndexSCANNSearchParam struct { //auto generated fields
 	baseSearchParams
 	


Test patch:
diff --git a/client/index_test.go b/client/index_test.go
index eea34bc..f1ca827 100644
--- a/client/index_test.go
+++ b/client/index_test.go
@@ -41,17 +41,6 @@ func TestGrpcClientCreateIndex(t *testing.T) {
 		assert.Nil(t, c.CreateIndex(ctx, testCollectionName, fieldName, idx, true))
 	})
 
-	t.Run("test flush err", func(t *testing.T) {
-		mockServer.SetInjection(MFlush, func(_ context.Context, raw proto.Message) (proto.Message, error) {
-			resp := &milvuspb.FlushResponse{}
-			s, err := BadRequestStatus()
-			resp.Status = s
-			return resp, err
-		})
-		defer mockServer.DelInjection(MFlush)
-		assert.NotNil(t, c.CreateIndex(ctx, testCollectionName, fieldName, idx, false))
-	})
-
 	t.Run("test sync create index", func(t *testing.T) {
 		buildTime := rand.Intn(900) + 100
 		start := time.Now()
diff --git a/entity/indexes_gen_test.go b/entity/indexes_gen_test.go
index cec8afb..e7fce9f 100755
--- a/entity/indexes_gen_test.go
+++ b/entity/indexes_gen_test.go
@@ -588,7 +588,7 @@ func TestIndexSCANN(t *testing.T){
 		assert.Nil(t, err)
 		assert.NotNil(t, idx0)
 		assert.Equal(t, "SCANN", idx0.Name())
-		assert.EqualValues(t, "IVF_FLAT", idx0.IndexType())
+		assert.EqualValues(t, "SCANN", idx0.IndexType())
 		assert.NotNil(t, idx0.Params())
 		assert.False(t, idx0.SupportBinary())
 		
@@ -600,7 +600,7 @@ func TestIndexSCANN(t *testing.T){
 		assert.Nil(t, err)
 		assert.NotNil(t, idx1)
 		assert.Equal(t, "SCANN", idx1.Name())
-		assert.EqualValues(t, "IVF_FLAT", idx1.IndexType())
+		assert.EqualValues(t, "SCANN", idx1.IndexType())
 		assert.NotNil(t, idx1.Params())
 		assert.False(t, idx1.SupportBinary())