mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Change searches to AND terms instead of OR
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user