From 750d4948e81e1ac6b6a63386b96f8c60828891e5 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 4 Jan 2025 20:28:41 +0100 Subject: refactor: extract pagination into module --- internal/index/search.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'internal/index') diff --git a/internal/index/search.go b/internal/index/search.go index d576d5a..9d77488 100644 --- a/internal/index/search.go +++ b/internal/index/search.go @@ -15,7 +15,7 @@ import ( "github.com/pkg/errors" ) -const ResultsPerPage = 100 +const DefaultPageSize = 100 type DocumentMatch struct { *search.DocumentMatch @@ -134,7 +134,8 @@ func (index *ReadIndex) Search( ctx context.Context, source *config.Source, keyword string, - from uint64, + from int, + pageSize int, ) (*Result, error) { query := bleve.NewBooleanQuery() @@ -175,10 +176,10 @@ func (index *ReadIndex) Search( search := bleve.NewSearchRequest(query) search.Explain = config.DevMode - search.Size = ResultsPerPage + search.Size = pageSize if from != 0 { - search.From = int(from) + search.From = from } return index.search(ctx, search) -- cgit 1.4.1