all repos — searchix @ 1328df9c5ca44e903a052c9bfc9a67dd34e25704

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: promote prefix/exact name/attr matches Fixes: https://todo.sr.ht/~alanpearce/searchix/18

Alan Pearce
commit

1328df9c5ca44e903a052c9bfc9a67dd34e25704

parent

d39204eadf673b6c7ae940203fd75c0805245a96

1 file changed, 8 insertions(+), 7 deletions(-)

changed files
M internal/index/indexer.gointernal/index/indexer.go
@@ -8,6 +8,7 @@ "io/fs"
"math" "os" "path" + "path/filepath" "slices" "go.alanpearce.eu/searchix/internal/file"
@@ -89,13 +90,6 @@ "token_filters": []string{
camelcase.Name, porter.Name, }, - }) - if err != nil { - return nil, errors.WithMessage(err, "could not add custom analyser") - } - err = indexMapping.AddCustomAnalyzer("keyword_single", map[string]any{ - "type": keyword.Name, - "tokenizer": letter.Name, }) if err != nil { return nil, errors.WithMessage(err, "could not add custom analyser")
@@ -222,6 +216,13 @@ options *Options,
) (*ReadIndex, *WriteIndex, bool, errors.E) { var err errors.E bleve.SetLog(zap.NewStdLog(options.Logger.Named("bleve").GetLogger())) + if !filepath.IsAbs(dataRoot) { + wd, err := os.Getwd() + if err != nil { + return nil, nil, false, errors.WithMessagef(err, "could not get working directory") + } + dataRoot = filepath.Join(wd, dataRoot) + } indexPath := path.Join(dataRoot, indexBaseName) metaPath := path.Join(dataRoot, metaBaseName)