|
|
@ -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{
|
|
|
|