go-common/app/admin/main/search/service/update.go

34 lines
932 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package service
import (
"context"
"fmt"
"go-common/app/admin/main/search/dao"
"go-common/library/ecode"
)
// Update update some indices.
func (s *Service) Update(c context.Context, esName string, bulkData []dao.BulkItem) (err error) {
if err = s.dao.UpdateBulk(c, esName, bulkData); err != nil {
dao.PromError(fmt.Sprintf("es:%s 更新失败", esName), "s.dao.updateBulk error(%v) ", err)
err = ecode.SearchUpdateIndexFailed
}
return
}
// MapUpdate map update.
func (s *Service) MapUpdate(c context.Context, p []dao.BulkMapItem) (err error) {
err = s.dao.UpdateMapBulk(c, "ssd_archive", p)
return
}
// Index .
func (s *Service) Index(c context.Context, esName string, bulkData []dao.BulkItem) (err error) {
if err = s.dao.BulkIndex(c, esName, bulkData); err != nil {
dao.PromError(fmt.Sprintf("es:%s 写入失败", esName), "s.dao.BulkIndex error(%v) ", err)
err = ecode.SearchUpdateIndexFailed
}
return
}