diff --git a/entity/index.go b/entity/index.go index eafdadeb..bf5717bc 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 06188ed1..5411e5a1 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)