diff options
author | George Goldberg <george@gberg.me> | 2018-01-05 15:59:10 +0000 |
---|---|---|
committer | Saturnino Abril <saturnino.abril@gmail.com> | 2018-01-05 23:59:10 +0800 |
commit | 143e664cd98aec9ee81ba953fd93704b7be33460 (patch) | |
tree | e3efdbe85ed73d9e812b706960dd5cd4c1a3ac65 /store/sqlstore/user_store.go | |
parent | a5bbf3f64366110c97a3d9d2014623ce0c224be4 (diff) | |
download | chat-143e664cd98aec9ee81ba953fd93704b7be33460.tar.gz chat-143e664cd98aec9ee81ba953fd93704b7be33460.tar.bz2 chat-143e664cd98aec9ee81ba953fd93704b7be33460.zip |
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.
Diffstat (limited to 'store/sqlstore/user_store.go')
-rw-r--r-- | store/sqlstore/user_store.go | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/store/sqlstore/user_store.go b/store/sqlstore/user_store.go index 5ecc1fdda..549377d61 100644 --- a/store/sqlstore/user_store.go +++ b/store/sqlstore/user_store.go @@ -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) } |