aboutsummaryrefslogtreecommitdiffstats
path: root/cache
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-03-28 23:26:58 +0200
committerMichael Muré <batolettre@gmail.com>2021-03-28 23:26:58 +0200
commit32958b5ca1901e8062bc67c9a03675ffd8ef4fa7 (patch)
tree0447be7847dd7d391046085551e042806013c719 /cache
parent919227c6dafffaa2e4c497c0a514d75dcf168045 (diff)
downloadgit-bug-32958b5ca1901e8062bc67c9a03675ffd8ef4fa7.tar.gz
cache: only FTS index token < 100 characters
Diffstat (limited to 'cache')
-rw-r--r--cache/repo_cache_bug.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/cache/repo_cache_bug.go b/cache/repo_cache_bug.go
index 1701f66d..8d9914e3 100644
--- a/cache/repo_cache_bug.go
+++ b/cache/repo_cache_bug.go
@@ -8,12 +8,14 @@ import (
"sort"
"strings"
"time"
+ "unicode/utf8"
+
+ "github.com/blevesearch/bleve"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/query"
"github.com/MichaelMure/git-bug/repository"
- "github.com/blevesearch/bleve"
)
const (
@@ -479,11 +481,24 @@ func (c *RepoCache) addBugToSearchIndex(snap *bug.Snapshot) error {
Text []string
}{}
+ // See https://github.com/blevesearch/bleve/issues/1576
+ var sb strings.Builder
+ normalize := func(text string) string {
+ sb.Reset()
+ for _, field := range strings.Fields(text) {
+ if utf8.RuneCountInString(field) < 100 {
+ sb.WriteString(field)
+ sb.WriteRune(' ')
+ }
+ }
+ return sb.String()
+ }
+
for _, comment := range snap.Comments {
- searchableBug.Text = append(searchableBug.Text, comment.Message)
+ searchableBug.Text = append(searchableBug.Text, normalize(comment.Message))
}
- searchableBug.Text = append(searchableBug.Text, snap.Title)
+ searchableBug.Text = append(searchableBug.Text, normalize(snap.Title))
index, err := c.repo.GetBleveIndex("bug")
if err != nil {