From cc774105c7ad747027e0c993cce659fecd6e213b Mon Sep 17 00:00:00 2001 From: Sergio Vera Date: Sun, 8 Sep 2024 16:51:00 +0200 Subject: [PATCH] Fixed not retrieving results for Uppercase accented words using lowercase non-accented counterparts --- internal/index/bleve.go | 12 ++++++------ internal/index/bleve_test.go | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/internal/index/bleve.go b/internal/index/bleve.go index 2de52b5..48459f9 100644 --- a/internal/index/bleve.go +++ b/internal/index/bleve.go @@ -24,7 +24,7 @@ import ( // Version identifies the mapping used for indexing. Any changes in the mapping requires an increase // of version, to signal that a new index needs to be created. -const Version = "v2" +const Version = "v3" // Metadata fields var ( @@ -33,11 +33,11 @@ var ( ) var noStopWordsFilters = map[string][]string{ - es.AnalyzerName: {es.NormalizeName, lowercase.Name, es.LightStemmerName}, - en.AnalyzerName: {en.PossessiveName, lowercase.Name, porter.Name}, - de.AnalyzerName: {de.NormalizeName, lowercase.Name, de.LightStemmerName}, - fr.AnalyzerName: {fr.ElisionName, lowercase.Name, fr.LightStemmerName}, - it.AnalyzerName: {it.ElisionName, lowercase.Name, it.LightStemmerName}, + es.AnalyzerName: {lowercase.Name, es.NormalizeName, es.LightStemmerName}, + en.AnalyzerName: {lowercase.Name, en.PossessiveName, porter.Name}, + de.AnalyzerName: {lowercase.Name, de.NormalizeName, de.LightStemmerName}, + fr.AnalyzerName: {lowercase.Name, fr.ElisionName, fr.LightStemmerName}, + it.AnalyzerName: {lowercase.Name, it.ElisionName, it.LightStemmerName}, pt.AnalyzerName: {lowercase.Name, pt.LightStemmerName}, } diff --git a/internal/index/bleve_test.go b/internal/index/bleve_test.go index 26b7184..20fa63d 100644 --- a/internal/index/bleve_test.go +++ b/internal/index/bleve_test.go @@ -290,5 +290,34 @@ func testCases() []testCase { }, ), }, + { + "Test spanish stemmer returning accented word while using unaccented word in search", + "lib/book9.epub", + metadata.Metadata{ + Title: "Últimos días en Colditz", + Authors: []string{"Patrick R. Reid"}, + Description: "Just test metadata", + Language: "es", + Subjects: []string{"History", "WWII"}, + }, + "ultimos", + result.NewPaginated[[]index.Document]( + model.ResultsPerPage, + 1, + 1, + []index.Document{ + { + ID: "book9.epub", + Slug: "patrick-r-reid-ultimos-dias-en-colditz", + Metadata: metadata.Metadata{ + Title: "Últimos días en Colditz", + Authors: []string{"Patrick R. Reid"}, + Description: "Just test metadata", + Subjects: []string{"History", "WWII"}, + }, + }, + }, + ), + }, } }