summaryrefslogtreecommitdiffstats
path: root/store/sql_post_store.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-05-09 12:00:08 -0400
committerCorey Hulen <corey@hulen.com>2016-05-09 09:00:08 -0700
commit07126101d379b900724c7c5cfc82070b42c235d6 (patch)
tree80b2485b61eb1684cd6127473267af206c3ab1c2 /store/sql_post_store.go
parent9e07f4b021b28a3e301359a48cf950298f3e552e (diff)
downloadchat-07126101d379b900724c7c5cfc82070b42c235d6.tar.gz
chat-07126101d379b900724c7c5cfc82070b42c235d6.tar.bz2
chat-07126101d379b900724c7c5cfc82070b42c235d6.zip
Recent mention searches now OR terms instead of AND (#2931)
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r--store/sql_post_store.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 54b526191..d7d009ce4 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -725,7 +725,11 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
terms = wildcard.ReplaceAllLiteralString(terms, ":* ")
}
- terms = strings.Join(strings.Fields(terms), " & ")
+ if params.OrTerms {
+ terms = strings.Join(strings.Fields(terms), " | ")
+ } else {
+ terms = strings.Join(strings.Fields(terms), " & ")
+ }
searchClause := fmt.Sprintf("AND %s @@ to_tsquery(:Terms)", searchType)
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1)
@@ -733,12 +737,14 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
searchClause := fmt.Sprintf("AND MATCH (%s) AGAINST (:Terms IN BOOLEAN MODE)", searchType)
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1)
- splitTerms := strings.Fields(terms)
- for i, t := range strings.Fields(terms) {
- splitTerms[i] = "+" + t
- }
+ if !params.OrTerms {
+ splitTerms := strings.Fields(terms)
+ for i, t := range strings.Fields(terms) {
+ splitTerms[i] = "+" + t
+ }
- terms = strings.Join(splitTerms, " ")
+ terms = strings.Join(splitTerms, " ")
+ }
}
queryParams["Terms"] = terms