From a9e62ef5a76eda643888c9a5eff5e48fefa84ed9 Mon Sep 17 00:00:00 2001 From: Patrick Weizhi Xu Date: Sat, 14 Sep 2024 15:27:04 +0800 Subject: [PATCH] feat: add page retain order for range search Signed-off-by: Patrick Weizhi Xu --- entity/index.go | 5 +++++ entity/index_test.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/entity/index.go b/entity/index.go index eafdadeb5..bf5717bc5 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{}), diff --git a/entity/index_test.go b/entity/index_test.go index 06188ed10..5411e5a1f 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)