diff options
author | Alan Pearce | 2025-01-04 20:28:41 +0100 |
---|---|---|
committer | Alan Pearce | 2025-01-04 20:28:41 +0100 |
commit | 750d4948e81e1ac6b6a63386b96f8c60828891e5 (patch) | |
tree | 8354b40cfb28bc154c89b47e37c74fca7f479fb6 /internal/index | |
parent | 3d9e6998177f7fc8e971df4913c3a880ff911c99 (diff) | |
download | searchix-750d4948e81e1ac6b6a63386b96f8c60828891e5.tar.lz searchix-750d4948e81e1ac6b6a63386b96f8c60828891e5.tar.zst searchix-750d4948e81e1ac6b6a63386b96f8c60828891e5.zip |
refactor: extract pagination into module
Diffstat (limited to 'internal/index')
-rw-r--r-- | internal/index/search.go | 9 |
1 files changed, 5 insertions, 4 deletions
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) |