summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--store/sqlstore/channel_store.go6
-rw-r--r--store/sqlstore/upgrade.go2
-rw-r--r--store/storetest/channel_store.go42
3 files changed, 47 insertions, 3 deletions
diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go
index eb88bc42a..e062d41d1 100644
--- a/store/sqlstore/channel_store.go
+++ b/store/sqlstore/channel_store.go
@@ -298,7 +298,7 @@ func (s SqlChannelStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_channelmembers_channel_id", "ChannelMembers", "ChannelId")
s.CreateIndexIfNotExists("idx_channelmembers_user_id", "ChannelMembers", "UserId")
- s.CreateFullTextIndexIfNotExists("idx_channels_txt", "Channels", "Name, DisplayName")
+ s.CreateFullTextIndexIfNotExists("idx_channel_search_txt", "Channels", "Name, DisplayName, Purpose")
}
func (s SqlChannelStore) Save(channel *model.Channel, maxChannelsPerTeam int64) store.StoreChannel {
@@ -1573,7 +1573,7 @@ func (s SqlChannelStore) SearchMore(userId string, teamId string, term string) s
func (s SqlChannelStore) buildLIKEClause(term string) (likeClause, likeTerm string) {
likeTerm = term
- searchColumns := "Name, DisplayName"
+ searchColumns := "Name, DisplayName, Purpose"
// These chars must be removed from the like query.
for _, c := range ignoreLikeSearchChar {
@@ -1608,7 +1608,7 @@ func (s SqlChannelStore) buildFulltextClause(term string) (fulltextClause, fullt
// Copy the terms as we will need to prepare them differently for each search type.
fulltextTerm = term
- searchColumns := "Name, DisplayName"
+ searchColumns := "Name, DisplayName, Purpose"
// These chars must be treated as spaces in the fulltext query.
for _, c := range spaceFulltextSearchChar {
diff --git a/store/sqlstore/upgrade.go b/store/sqlstore/upgrade.go
index 65c2c11e2..fc2d53235 100644
--- a/store/sqlstore/upgrade.go
+++ b/store/sqlstore/upgrade.go
@@ -446,6 +446,8 @@ func UpgradeDatabaseToVersion50(sqlStore SqlStore) {
sqlStore.GetMaster().Exec("UPDATE Roles SET SchemeManaged=false WHERE Name NOT IN ('system_user', 'system_admin', 'team_user', 'team_admin', 'channel_user', 'channel_admin')")
sqlStore.CreateColumnIfNotExists("IncomingWebhooks", "ChannelLocked", "boolean", "boolean", "0")
+ sqlStore.RemoveIndexIfExists("idx_channels_txt", "Channels")
+
saveSchemaVersion(sqlStore, VERSION_5_0_0)
}
}
diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go
index ecec7fab9..b033e9c98 100644
--- a/store/storetest/channel_store.go
+++ b/store/storetest/channel_store.go
@@ -1708,6 +1708,14 @@ func testChannelStoreSearchMore(t *testing.T, ss store.Store) {
o8.Type = model.CHANNEL_PRIVATE
store.Must(ss.Channel().Save(&o8, -1))
+ o9 := model.Channel{}
+ o9.TeamId = o1.TeamId
+ o9.DisplayName = "Channel With Purpose"
+ o9.Purpose = "This can now be searchable!"
+ o9.Name = "with-purpose"
+ o9.Type = model.CHANNEL_OPEN
+ store.Must(ss.Channel().Save(&o9, -1))
+
if result := <-ss.Channel().SearchMore(m1.UserId, o1.TeamId, "ChannelA"); result.Err != nil {
t.Fatal(result.Err)
} else {
@@ -1773,6 +1781,19 @@ func testChannelStoreSearchMore(t *testing.T, ss store.Store) {
}
}
+ if result := <-ss.Channel().SearchMore(m1.UserId, o1.TeamId, "now searchable"); result.Err != nil {
+ t.Fatal(result.Err)
+ } else {
+ channels := result.Data.(*model.ChannelList)
+ if len(*channels) != 1 {
+ t.Fatal("should return 1 channel")
+ }
+
+ if (*channels)[0].Name != o9.Name {
+ t.Fatal("wrong channel returned")
+ }
+ }
+
/*
// Disabling this check as it will fail on PostgreSQL as we have "liberalised" channel matching to deal with
// Full-Text Stemming Limitations.
@@ -1884,6 +1905,14 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) {
o11.Type = model.CHANNEL_OPEN
store.Must(ss.Channel().Save(&o11, -1))
+ o12 := model.Channel{}
+ o12.TeamId = o1.TeamId
+ o12.DisplayName = "Channel With Purpose"
+ o12.Purpose = "This can now be searchable!"
+ o12.Name = "with-purpose"
+ o12.Type = model.CHANNEL_OPEN
+ store.Must(ss.Channel().Save(&o12, -1))
+
for name, search := range map[string]func(teamId string, term string) store.StoreChannel{
"AutocompleteInTeam": ss.Channel().AutocompleteInTeam,
"SearchInTeam": ss.Channel().SearchInTeam,
@@ -1986,6 +2015,19 @@ func testChannelStoreSearchInTeam(t *testing.T, ss store.Store) {
t.Fatal("wrong channel returned")
}
}
+
+ if result := <-search(o1.TeamId, "now searchable"); result.Err != nil {
+ t.Fatal(result.Err)
+ } else {
+ channels := result.Data.(*model.ChannelList)
+ if len(*channels) != 1 {
+ t.Fatal("should return 1 channel")
+ }
+
+ if (*channels)[0].Name != o12.Name {
+ t.Fatal("wrong channel returned")
+ }
+ }
})
}
}