Skip to content

Commit

Permalink
search/bleve: make fuzzy less fuzzy
Browse files Browse the repository at this point in the history
attempt to fix the stopword removal again
  • Loading branch information
Wessie committed Jun 26, 2024
1 parent 4876ddf commit b2aa9db
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions search/bleve/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ func mixedTextMapping() *mapping.FieldMapping {
func constructIndexMapping() (mapping.IndexMapping, error) {
im := bleve.NewIndexMapping()
im.DefaultType = "song"
im.DefaultField = "title"

// create a mapping for our radio.Song type
sm := bleve.NewDocumentStaticMapping()
sm.StructTagKey = "bleve"
sm.DefaultAnalyzer = "radio"

title := mixedTextMapping()
sm.AddFieldMappingsAt("title", title)
Expand Down Expand Up @@ -255,7 +257,6 @@ func constructIndexMapping() (mapping.IndexMapping, error) {
data := bleve.NewTextFieldMapping()
data.Index = false
data.Store = true
data.Analyzer = "radio" // same as the actual text fields we index
sm.AddFieldMappingsAt("data", data)

// register the song mapping
Expand Down Expand Up @@ -339,15 +340,13 @@ func addFuzzy(qs []query.Query) {
fq.SetFuzziness(1)
}
case *query.FuzzyQuery:
if len(fq.Term) > fuzzyMin {
if len(fq.Term) > fuzzyMin && fq.Fuzziness == 0 {
fq.SetFuzziness(1)
}
case *query.MatchPhraseQuery:
if len(fq.MatchPhrase) > fuzzyMin {
fq.SetFuzziness(1)
}
case interface{ SetFuzziness(int) }:
fq.SetFuzziness(1)
}
}
}

0 comments on commit b2aa9db

Please sign in to comment.