all repos — searchix @ 72d56a6781e97cde13ba068e8553e9342bd1fa20

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

feat: apply stemming to search index terms
Alan Pearce alan@alanpearce.eu
Wed, 20 Nov 2024 11:14:49 +0100
commit

72d56a6781e97cde13ba068e8553e9342bd1fa20

parent

7cbe90e090634f48086f6c64bb976a2c962bb2d2

1 files changed, 6 insertions(+), 0 deletions(-)

jump to
M internal/index/indexer.gointernal/index/indexer.go
@@ -20,6 +20,7 @@ "github.com/blevesearch/bleve/v2/analysis/analyzer/custom" 	"github.com/blevesearch/bleve/v2/analysis/analyzer/keyword"
 	"github.com/blevesearch/bleve/v2/analysis/analyzer/web"
 	"github.com/blevesearch/bleve/v2/analysis/token/camelcase"
+	"github.com/blevesearch/bleve/v2/analysis/token/porter"
 	"github.com/blevesearch/bleve/v2/analysis/tokenizer/letter"
 	"github.com/blevesearch/bleve/v2/analysis/tokenizer/single"
 	"github.com/blevesearch/bleve/v2/document"
@@ -61,6 +62,7 @@ "type":      custom.Name, 		"tokenizer": letter.Name,
 		"token_filters": []string{
 			camelcase.Name,
+			porter.Name,
 		},
 	})
 	if err != nil {
@@ -71,6 +73,7 @@ "type":      keyword.Name, 		"tokenizer": letter.Name,
 		"token_filters": []string{
 			camelcase.Name,
+			porter.Name,
 		},
 	})
 	if err != nil {
@@ -79,6 +82,9 @@ } 	err = indexMapping.AddCustomAnalyzer("keyword_single", map[string]interface{}{
 		"type":      keyword.Name,
 		"tokenizer": single.Name,
+		"token_filters": []string{
+			porter.Name,
+		},
 	})
 	if err != nil {
 		return nil, errors.WithMessage(err, "could not add custom analyser")