Repository: milvus-io/milvus-sdk-go
Pull request #813 (2024-08-30 03:43:54)

feat: add page retain order
issue: https://github.com/milvus-io/milvus/issues/35464

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/813#" title="Author self-approved">PwzXxm</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/master/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"]} -->
PwzXxm: /hold
PwzXxm: /unhold
PwzXxm: Waiting for CI Fix.
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/813#pullrequestreview-2304408223" title="LGTM">congqixia</a>*, *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/813#" title="Author self-approved">PwzXxm</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/entity/index.go b/entity/index.go
index eafdade..bf5717b 100644
--- a/entity/index.go
+++ b/entity/index.go
@@ -89,6 +89,7 @@ type SearchParam interface {
 	Params() map[string]interface{}
 	AddRadius(radius float64)
 	AddRangeFilter(rangeFilter float64)
+	AddPageRetainOrder(pageRetainOrder bool)
 }
 
 type baseSearchParams struct {
@@ -111,6 +112,10 @@ func (sp *baseSearchParams) AddRangeFilter(rangeFilter float64) {
 	sp.params["range_filter"] = rangeFilter
 }
 
+func (sp *baseSearchParams) AddPageRetainOrder(pageRetainOrder bool) {
+	sp.params["page_retain_order"] = pageRetainOrder
+}
+
 func newBaseSearchParams() baseSearchParams {
 	return baseSearchParams{
 		params: make(map[string]interface{}),


Test patch:
diff --git a/entity/index_test.go b/entity/index_test.go
index 06188ed..5411e5a 100644
--- a/entity/index_test.go
+++ b/entity/index_test.go
@@ -41,6 +41,12 @@ func TestAddRangeFilter(t *testing.T) {
 	assert.Equal(t, params.Params()["range_filter"], float64(20))
 }
 
+func TestPageRetainOrder(t *testing.T) {
+	params := newBaseSearchParams()
+	params.AddPageRetainOrder(true)
+	assert.Equal(t, params.Params()["page_retain_order"], true)
+}
+
 func TestIndexGPUCagra(t *testing.T) {
 	t.Run("index", func(t *testing.T) {
 		index, err := NewIndexGPUCagra(L2, 64, 64)