// EnsureIndexes ensure indexes for collection of the day
EnsureIndexes ensure indexes for collection of the day
// EnsureIndexes ensure indexes for collection of the day
func (d *MongoDB) EnsureIndexes(t time.Time) (err error) {
	coll := d.Collection(t)
	for _, field := range PlainIndexedFields {
		if err = coll.EnsureIndex(mgo.Index{
			Key:        []string{field},
			Background: true,
		}); err != nil {
			return
		}
	}
	keys := make([]string, 0)
	for _, field := range TextIndexedFields {
		keys = append(keys, "$text:"+field)
	}
	if err = coll.EnsureIndex(mgo.Index{
		Key:        keys,
		Background: true,
	}); err != nil {
		return
	}
	return
}
func ( d * MongoDB ) EnsureIndexes ( t time . Time ) ( err error ) { coll := d . Collection ( t ) for _ , field := range PlainIndexedFields { if err = coll . EnsureIndex ( mgo . Index { Key : [ ] string { field } , Background : true , } ) ; err != nil { return } } keys := make ( [ ] string , 0 ) for _ , field := range TextIndexedFields { keys = append ( keys , " " + field ) } if err = coll . EnsureIndex ( mgo . Index { Key : keys , Background : true , } ) ; err != nil { return } return }
EnsureIndexes ensure indexes for collection of the day
EnsureIndexes ensure indexes for collection of the day
// plain indexes // text indexes, should be compounded, because mongo support only one text index