Repository: milvus-io/milvus-sdk-go
Pull request #816 (2024-09-11 07:05:24)

feat: [2.4]add page retain order for range search
issue: https://github.com/milvus-io/milvus/issues/35464

Signed-off-by: Patrick Weizhi Xu <weizhi.xu@zilliz.com>
(cherry picked from commit a1f6fffa86d5c75873bbe0a828bd68cc0dd37c38)

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/816#" 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 **sunby** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @sunby` 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":["sunby"]} -->
congqixia: /kind feature
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/816#pullrequestreview-2464354749" title="LGTM">congqixia</a>*, *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/816#" 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/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/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)