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 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运行状态
docker compose ps
NAME COMMAND SERVICE STATUS PORTS
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配置

@ -59,12 +59,12 @@ func (s *meiliTweetSearchServant) IndexName() string {
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)
if len(docs) == 0 {
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)
return false, err
}

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

Loading…
Cancel
Save