-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improving clan search route latency with mongoDB text index search (#43)
- Loading branch information
1 parent
25b2fa0
commit 23e8395
Showing
7 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package testing | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/globalsign/mgo/bson" | ||
"github.com/topfreegames/extensions/mongo/interfaces" | ||
) | ||
|
||
// CreateClanNameTextIndexInMongo creates the necessary text index for clan search in mongo | ||
func CreateClanNameTextIndexInMongo(getTestMongo func() (interfaces.MongoDB, error), gameID string) error { | ||
mongo, err := getTestMongo() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cmd := bson.D{ | ||
{Name: "createIndexes", Value: fmt.Sprintf("clans_%s", gameID)}, | ||
{Name: "indexes", Value: []interface{}{ | ||
bson.M{ | ||
"key": bson.M{ | ||
"name": "text", | ||
}, | ||
"name": fmt.Sprintf("clans_%s_name_text_index", gameID), | ||
}, | ||
}}, | ||
} | ||
return mongo.Run(cmd, nil) | ||
} |