From 72d56a6781e97cde13ba068e8553e9342bd1fa20 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 20 Nov 2024 11:14:49 +0100 Subject: feat: apply stemming to search index terms --- internal/index/indexer.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'internal/index/indexer.go') diff --git a/internal/index/indexer.go b/internal/index/indexer.go index 47701bd..476ca29 100644 --- a/internal/index/indexer.go +++ b/internal/index/indexer.go @@ -20,6 +20,7 @@ import ( "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 @@ func createIndexMapping() (mapping.IndexMapping, error) { "tokenizer": letter.Name, "token_filters": []string{ camelcase.Name, + porter.Name, }, }) if err != nil { @@ -71,6 +73,7 @@ func createIndexMapping() (mapping.IndexMapping, error) { "tokenizer": letter.Name, "token_filters": []string{ camelcase.Name, + porter.Name, }, }) if err != nil { @@ -79,6 +82,9 @@ func createIndexMapping() (mapping.IndexMapping, error) { 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") -- cgit 1.4.1