From 05e61978906a08132c4340a5f9ae518134dd0fa9 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 17 May 2024 14:06:06 +0200 Subject: feat: support searching packages --- internal/index/search.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'internal/index/search.go') 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" -- cgit 1.4.1