upgrade meilisearch version => v1.1.1

pull/288/head
Michael Li 2 years ago
parent d34068a8c3
commit 595ac792b8
No known key found for this signature in database

@ -433,19 +433,10 @@ docker run -d --name meili -v ${PWD}/data/meili/data:/meili_data -p 7700:7700 -e
# 使用docker compose运行需要删除docker-compose.yaml中关于meili的注释 # 使用docker compose运行需要删除docker-compose.yaml中关于meili的注释
docker compose up -d meili docker compose up -d meili
# 使用docker运行meilisearch的ui管理前端
docker run -d --name uirecord -p 7701:3000 bitriory/uirecord
# visit http://localhost:7701
# 使用docker compose运行meilisearch的ui管理前端需要删除docker-compose.yaml中关于uirecord的注释
docker compose up -d uirecord
# visit http://loclahost:7701
# 查看meili运行状态 # 查看meili运行状态
docker compose ps docker compose ps
NAME COMMAND SERVICE STATUS PORTS NAME COMMAND SERVICE STATUS PORTS
paopao-ce-meili-1 "tini -- /bin/sh -c …" meili running 0.0.0.0:7700->7700/tcp paopao-ce-meili-1 "tini -- /bin/sh -c …" meili running 0.0.0.0:7700->7700/tcp
paopao-ce-uirecord-1 "docker-entrypoint.s…" uirecord running 0.0.0.0:7701->3000/tcp
``` ```
* 修改Meili配置 * 修改Meili配置

@ -59,12 +59,12 @@ func (s *meiliTweetSearchServant) IndexName() string {
return s.index.UID return s.index.UID
} }
func (s *meiliTweetSearchServant) AddDocuments(data []core.TsDocItem, primaryKey ...string) (bool, error) { func (s *meiliTweetSearchServant) AddDocuments(data []core.TsDocItem, _primaryKey ...string) (bool, error) {
docs := s.toDocs(data) docs := s.toDocs(data)
if len(docs) == 0 { if len(docs) == 0 {
return true, nil return true, nil
} }
if _, err := s.index.AddDocuments(docs, primaryKey...); err != nil { if _, err := s.index.AddDocuments(docs); err != nil {
logrus.Errorf("meiliTweetSearchServant.AddDocuments error: %s", err) logrus.Errorf("meiliTweetSearchServant.AddDocuments error: %s", err)
return false, err return false, err
} }

@ -22,19 +22,22 @@ func NewMeiliTweetSearchService(ams core.AuthorizationManageService) (core.Tweet
}) })
if _, err := client.Index(s.Index).FetchInfo(); err != nil { if _, err := client.Index(s.Index).FetchInfo(); err != nil {
logrus.Debugf("create index because fetch index info error: %v", err) logrus.Debugf("create meili index because fetch index info error: %v", err)
client.CreateIndex(&meilisearch.IndexConfig{ if _, err := client.CreateIndex(&meilisearch.IndexConfig{
Uid: s.Index, Uid: s.Index,
PrimaryKey: "id", PrimaryKey: "id",
}) }); err == nil {
searchableAttributes := []string{"content", "tags"} settings := meilisearch.Settings{
sortableAttributes := []string{"is_top", "latest_replied_on"} SearchableAttributes: []string{"content", "tags"},
filterableAttributes := []string{"tags", "visibility", "user_id"} SortableAttributes: []string{"is_top", "latest_replied_on"},
FilterableAttributes: []string{"tags", "visibility", "user_id"},
index := client.Index(s.Index) }
index.UpdateSearchableAttributes(&searchableAttributes) if _, err = client.Index(s.Index).UpdateSettings(&settings); err != nil {
index.UpdateSortableAttributes(&sortableAttributes) logrus.Errorf("update meili settings error: %s", err)
index.UpdateFilterableAttributes(&filterableAttributes) }
} else {
logrus.Errorf("create meili index error: %s", err)
}
} }
mts := &meiliTweetSearchServant{ mts := &meiliTweetSearchServant{

Loading…
Cancel
Save