diff options
author | Alan Pearce | 2024-05-17 14:06:06 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-17 14:06:06 +0200 |
commit | 05e61978906a08132c4340a5f9ae518134dd0fa9 (patch) | |
tree | 0ab5e550a1fe5aaf560459c40eccfdc00e298515 /internal/index/search.go | |
parent | 42611df8133fc88bac5947a65a18fa095d68a951 (diff) | |
download | searchix-05e61978906a08132c4340a5f9ae518134dd0fa9.tar.lz searchix-05e61978906a08132c4340a5f9ae518134dd0fa9.tar.zst searchix-05e61978906a08132c4340a5f9ae518134dd0fa9.zip |
feat: support searching packages
Diffstat (limited to 'internal/index/search.go')
-rw-r--r-- | internal/index/search.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/internal/index/search.go b/internal/index/search.go index a86cc02..5c18edb 100644 --- a/internal/index/search.go +++ b/internal/index/search.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "encoding/gob" + "searchix/internal/config" "searchix/internal/nix" "github.com/blevesearch/bleve/v2" @@ -15,7 +16,7 @@ const ResultsPerPage = 20 type DocumentMatch struct { search.DocumentMatch - Data nix.Option + Data nix.Importable } type Result struct { @@ -53,11 +54,12 @@ func (index *ReadIndex) GetSource(ctx context.Context, name string) (*bleve.Sear func (index *ReadIndex) Search( ctx context.Context, - source string, + source *config.Source, keyword string, from uint64, ) (*Result, error) { - sourceQuery := bleve.NewTermQuery(source) + sourceQuery := bleve.NewTermQuery(source.Key) + sourceQuery.SetField("Source") userQuery := bleve.NewMatchQuery(keyword) userQuery.Analyzer = "option_name" |