about summary refs log tree commit diff stats
path: root/internal/index
diff options
context:
space:
mode:
authorAlan Pearce2025-01-04 20:28:41 +0100
committerAlan Pearce2025-01-04 20:28:41 +0100
commit750d4948e81e1ac6b6a63386b96f8c60828891e5 (patch)
tree8354b40cfb28bc154c89b47e37c74fca7f479fb6 /internal/index
parent3d9e6998177f7fc8e971df4913c3a880ff911c99 (diff)
downloadsearchix-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.go9
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)