Repository: milvus-io/milvus-sdk-go
Pull request #844 (2024-11-12 02:55:44)

enhance: [2.4] let level param accepts more types

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

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/844#" title="Author self-approved">chasingegg</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **yah01** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @yah01` in a comment when ready.

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).

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

- **[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/v2.4.x/OWNERS)**

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":["yah01"]} -->
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/844#" title="Author self-approved">chasingegg</a>*, *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/844#pullrequestreview-2431773008" title="LGTM">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/v2.4.x/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/entity/genidx/genidx.go b/entity/genidx/genidx.go
index 4a4a63f..bb73748 100644
--- a/entity/genidx/genidx.go
+++ b/entity/genidx/genidx.go
@@ -621,8 +621,8 @@ func main() {
 				ConstructParams: []idxParam{},
 				SearchParams: []idxParam{
 					{
-						Name:           "level",
-						ValidationRule: "[1, 9223372036854775807]",
+						Name: "level",
+						Type: "interface{}",
 					},
 				},
 				ValidExamples: []string{
@@ -632,10 +632,6 @@ func main() {
 				ValidSearchParams: []string{
 					"level = 1",
 				},
-				InvalidSearchParams: []string{
-					"level = 0",
-					"level = -1",
-				},
 			},
 			{
 				IdxName: "GPUIvfFlat",
diff --git a/entity/indexes_search_param_gen.go b/entity/indexes_search_param_gen.go
index 1c7efd2..124d2cc 100755
--- a/entity/indexes_search_param_gen.go
+++ b/entity/indexes_search_param_gen.go
@@ -293,20 +293,15 @@ var _ SearchParam = &IndexAUTOINDEXSearchParam{}
 type IndexAUTOINDEXSearchParam struct { //auto generated fields
 	baseSearchParams
 	
-	level int
+	level interface{}
 }
 
 // NewIndexAUTOINDEXSearchParam create index search param
 func NewIndexAUTOINDEXSearchParam(
-	level int,
+	level interface{},
 ) (*IndexAUTOINDEXSearchParam, error) {
 	// auto generate parameters validation code, if any
-	if level < 1 {
-		return nil, errors.New("level has to be in range [1, 9223372036854775807]")
-	}
-	if level > 9223372036854775807 {
-		return nil, errors.New("level has to be in range [1, 9223372036854775807]")
-	}
+	
 	
 	sp := &IndexAUTOINDEXSearchParam{
 		baseSearchParams: newBaseSearchParams(),


Test patch:
diff --git a/entity/indexes_search_param_gen_test.go b/entity/indexes_search_param_gen_test.go
index 18c4d99..07897c6 100755
--- a/entity/indexes_search_param_gen_test.go
+++ b/entity/indexes_search_param_gen_test.go
@@ -336,7 +336,7 @@ func TestIndexDISKANNSearchParam(t *testing.T) {
 
 func TestIndexAUTOINDEXSearchParam(t *testing.T) {
 	
-	var level int
+	var level interface{}
 
 	t.Run("valid usage case", func(t *testing.T){
 		
@@ -350,24 +350,6 @@ func TestIndexAUTOINDEXSearchParam(t *testing.T) {
 		
 	})
 	
-	t.Run("invalid usage case", func(t *testing.T){
-		
-		level = 0
-		idx0, err := NewIndexAUTOINDEXSearchParam(
-			level,
-		)
-		assert.NotNil(t, err)
-		assert.Nil(t, idx0)
-		
-		level = -1
-		idx1, err := NewIndexAUTOINDEXSearchParam(
-			level,
-		)
-		assert.NotNil(t, err)
-		assert.Nil(t, idx1)
-		
-	})
-	
 }
 
 func TestIndexGPUIvfFlatSearchParam(t *testing.T) {