chore: store mongodb

This commit is contained in:
deepzz0
2021-04-26 23:02:24 +08:00
parent 68e01cdf1f
commit e2df642a46
20 changed files with 488 additions and 193 deletions

View File

@@ -12,7 +12,7 @@ import (
"strings"
"time"
"github.com/eiblog/eiblog/v2/pkg/config"
"github.com/eiblog/eiblog/pkg/config"
"github.com/sirupsen/logrus"
)
@@ -30,7 +30,7 @@ func init() {
}
mappings := fmt.Sprintf(`{"mappings":{"%s":{"properties":{"content":{"analyzer":"ik_syno","search_analyzer":"ik_syno","term_vector":"with_positions_offsets","type":"string"},"date":{"index":"not_analyzed","type":"date"},"slug":{"type":"string"},"tag":{"index":"not_analyzed","type":"string"},"title":{"analyzer":"ik_syno","search_analyzer":"ik_syno","term_vector":"with_positions_offsets","type":"string"}}}}}`, "article")
err := createIndexAndMappings("article", "eiblog", []byte(mappings))
err := createIndexAndMappings("eiblog", "article", []byte(mappings))
if err != nil {
panic(err)
}
@@ -130,7 +130,7 @@ func createIndexAndMappings(index, typ string, mappings []byte) error {
result := indicesCreateResult{}
err = json.Unmarshal(data, &result)
if err != nil {
return err
return errors.New(string(data))
}
if !result.Acknowledged {
return errors.New(string(data))