Skip to content

Commit

Permalink
Fixed not retrieving results for Uppercase accented words using lower…
Browse files Browse the repository at this point in the history
…case non-accented counterparts
  • Loading branch information
svera committed Sep 8, 2024
1 parent d0ab900 commit cc77410
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/index/bleve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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},
}

Expand Down
29 changes: 29 additions & 0 deletions internal/index/bleve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
},
},
),
},
}
}

0 comments on commit cc77410

Please sign in to comment.