summaryrefslogtreecommitdiffstats
path: root/store/sql_post_store.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2016-03-18 12:13:32 -0400
committerJoramWilander <jwawilander@gmail.com>2016-03-18 12:13:32 -0400
commit5b7a87bd8ec4cced5ef5e9a6a7d943cd8594b930 (patch)
tree6c3b1914b8d979a8bc9f3587a6987d3a27604e27 /store/sql_post_store.go
parent63273d6c164990f596ba72d87b1d566378a099f6 (diff)
downloadchat-5b7a87bd8ec4cced5ef5e9a6a7d943cd8594b930.tar.gz
chat-5b7a87bd8ec4cced5ef5e9a6a7d943cd8594b930.tar.bz2
chat-5b7a87bd8ec4cced5ef5e9a6a7d943cd8594b930.zip
Change searches to AND terms instead of OR
Diffstat (limited to 'store/sql_post_store.go')
-rw-r--r--store/sql_post_store.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 3346534ab..68c22f7f6 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -726,13 +726,20 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
terms = wildcard.ReplaceAllLiteralString(terms, ":* ")
}
- terms = strings.Join(strings.Fields(terms), " | ")
+ terms = strings.Join(strings.Fields(terms), " & ")
searchClause := fmt.Sprintf("AND %s @@ to_tsquery(:Terms)", searchType)
searchQuery = strings.Replace(searchQuery, "SEARCH_CLAUSE", searchClause, 1)
} else if utils.Cfg.SqlSettings.DriverName == model.DATABASE_DRIVER_MYSQL {
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
+ }
+
+ terms = strings.Join(splitTerms, " ")
}
queryParams["Terms"] = terms