diff options
author | George Goldberg <george@gberg.me> | 2017-05-18 16:26:52 +0100 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2017-05-18 11:26:52 -0400 |
commit | 0db5e3922fd5045b3f7f518ad65e42138f0325c4 (patch) | |
tree | e225a7191de7915a3da3716601ddb415c4f26979 /store/sql_post_store.go | |
parent | 2bbedd9def2a782f370fb5280994ea0ecbf8a7c7 (diff) | |
download | chat-0db5e3922fd5045b3f7f518ad65e42138f0325c4.tar.gz chat-0db5e3922fd5045b3f7f518ad65e42138f0325c4.tar.bz2 chat-0db5e3922fd5045b3f7f518ad65e42138f0325c4.zip |
PLT-6472: Basic Elastic Search implementation. (#6382)
* PLT-6472: Basic Elastic Search implementation.
This currently supports indexing of posts at create/update/delete time.
It does not support batch indexing or reindexing, and does not support
any entities other than posts yet. The purpose is to more-or-less
replicate the existing full-text search feature but with some of the
immediate benefits of using elastic search.
* Alter settings for AWS compatability.
* Remove unneeded i18n strings.
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r-- | store/sql_post_store.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go index b2211a180..834e488a8 100644 --- a/store/sql_post_store.go +++ b/store/sql_post_store.go @@ -1287,3 +1287,30 @@ func (s SqlPostStore) GetPostsCreatedAt(channelId string, time int64) StoreChann return storeChannel } + +func (s SqlPostStore) GetPostsByIds(postIds []string) StoreChannel { + storeChannel := make(StoreChannel, 1) + + go func() { + result := StoreResult{} + + inClause := `'` + strings.Join(postIds, `', '`) + `'` + + query := `SELECT * FROM Posts WHERE Id in (` + inClause + `) and DeleteAt = 0 ORDER BY CreateAt DESC` + + var posts []*model.Post + _, err := s.GetReplica().Select(&posts, query, map[string]interface{}{}) + + if err != nil { + l4g.Error(err) + result.Err = model.NewAppError("SqlPostStore.GetPostsCreatedAt", "store.sql_post.get_posts_by_ids.app_error", nil, "", http.StatusInternalServerError) + } else { + result.Data = posts + } + + storeChannel <- result + close(storeChannel) + }() + + return storeChannel +} |