mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
PLT-8312: Use combined LIKE/Full Text search for channels. (#8029)
* PLT-8312: Use combined LIKE/Full Text search for channels. * Code tidyup * Get it working consistently and update unit tests. * Fix code style.
This commit is contained in:
committed by
Saturnino Abril
parent
a5bbf3f643
commit
143e664cd9
@@ -1022,15 +1022,30 @@ func (us SqlUserStore) SearchInChannel(channelId string, term string, options ma
|
||||
})
|
||||
}
|
||||
|
||||
var escapeUserSearchChar = []string{
|
||||
var escapeLikeSearchChar = []string{
|
||||
"%",
|
||||
"_",
|
||||
}
|
||||
|
||||
var ignoreUserSearchChar = []string{
|
||||
var ignoreLikeSearchChar = []string{
|
||||
"*",
|
||||
}
|
||||
|
||||
var spaceFulltextSearchChar = []string{
|
||||
"<",
|
||||
">",
|
||||
"+",
|
||||
"-",
|
||||
"(",
|
||||
")",
|
||||
"~",
|
||||
":",
|
||||
"*",
|
||||
"\"",
|
||||
"!",
|
||||
"@",
|
||||
}
|
||||
|
||||
func generateSearchQuery(searchQuery string, terms []string, fields []string, parameters map[string]interface{}, isPostgreSQL bool) string {
|
||||
searchTerms := []string{}
|
||||
for i, term := range terms {
|
||||
@@ -1054,12 +1069,12 @@ func (us SqlUserStore) performSearch(searchQuery string, term string, options ma
|
||||
result := store.StoreResult{}
|
||||
|
||||
// These chars must be removed from the like query.
|
||||
for _, c := range ignoreUserSearchChar {
|
||||
for _, c := range ignoreLikeSearchChar {
|
||||
term = strings.Replace(term, c, "", -1)
|
||||
}
|
||||
|
||||
// These chars must be escaped in the like query.
|
||||
for _, c := range escapeUserSearchChar {
|
||||
for _, c := range escapeLikeSearchChar {
|
||||
term = strings.Replace(term, c, "*"+c, -1)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user