summaryrefslogtreecommitdiffstats
path: root/store/sql_post_store.go
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2015-07-05 09:02:23 -0800
committer=Corey Hulen <corey@hulen.com>2015-07-05 09:02:23 -0800
commit592d68cf4134b668e3ff962d17f8aa75b1bc055f (patch)
tree6e743b07487caf5fe350439aefdf0355a7e80d9b /store/sql_post_store.go
parent72bfc1ee2afd2fa4a34186b62f144f8f6c50d693 (diff)
parent4a3003c0dcf7d642f233493e32b07beed5d08327 (diff)
downloadchat-592d68cf4134b668e3ff962d17f8aa75b1bc055f.tar.gz
chat-592d68cf4134b668e3ff962d17f8aa75b1bc055f.tar.bz2
chat-592d68cf4134b668e3ff962d17f8aa75b1bc055f.zip
Merge branch 'master' into mm-1391
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r--store/sql_post_store.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 0ceebc02f..01900023f 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -356,9 +356,14 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht
go func() {
result := StoreResult{}
+ termMap := map[string]bool{}
+
searchType := "Message"
if isHashtagSearch {
searchType = "Hashtags"
+ for _,term := range strings.Split(terms, " ") {
+ termMap[term] = true;
+ }
}
// @ has a speical meaning in INNODB FULLTEXT indexes and
@@ -394,6 +399,17 @@ func (s SqlPostStore) Search(teamId string, userId string, terms string, isHasht
list := &model.PostList{Order: make([]string, 0, len(posts))}
for _, p := range posts {
+ if searchType == "Hashtags" {
+ exactMatch := false
+ for _, tag := range strings.Split(p.Hashtags, " ") {
+ if termMap[tag] {
+ exactMatch = true
+ }
+ }
+ if !exactMatch {
+ continue
+ }
+ }
list.AddPost(p)
list.AddOrder(p.Id)
}