diff --git a/internal/conf/logger_meili.go b/internal/conf/logger_meili.go index 51a275c4..ee08e34e 100644 --- a/internal/conf/logger_meili.go +++ b/internal/conf/logger_meili.go @@ -22,11 +22,13 @@ func (h *meiliLogHook) Fire(entry *logrus.Entry) error { "data": entry.Data, }} - // 先尝试进log缓存,否则直接加文档 + // 先尝试进log缓存,否则直接新开goroutine加文档 select { case h.addDocsCh <- &data: default: - h.index().AddDocuments(data) + go func(index *meilisearch.Index, item meiliLogData) { + index.AddDocuments(item) + }(h.index(), data) } return nil diff --git a/internal/dao/search_meili.go b/internal/dao/search_meili.go index 12d7335c..b3d93a2d 100644 --- a/internal/dao/search_meili.go +++ b/internal/dao/search_meili.go @@ -50,12 +50,10 @@ func (s *meiliTweetSearchServant) IndexName() string { } func (s *meiliTweetSearchServant) AddDocuments(data core.DocItems, primaryKey ...string) (bool, error) { - task, err := s.index.AddDocuments(data, primaryKey...) - if err != nil { + if _, err := s.index.AddDocuments(data, primaryKey...); err != nil { logrus.Errorf("meiliTweetSearchServant.AddDocuments error: %v", err) return false, err } - logrus.Debugf("meiliTweetSearchServant.AddDocuments task: %+v", task.Details) return true, nil }