-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
46_create_elastic_index_joins.go
54 lines (48 loc) · 1.1 KB
/
46_create_elastic_index_joins.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package migrations
import (
"context"
"github.com/Seklfreak/Robyul2/cache"
)
func m46_create_elastic_index_joins() {
if !cache.HasElastic() {
return
}
elastic := cache.GetElastic()
exists, err := elastic.IndexExists("robyul-joins").Do(context.Background())
if err != nil {
panic(err)
}
if exists {
return
}
joinMapping := map[string]interface{}{
"mappings": map[string]interface{}{
"doc": map[string]interface{}{
"properties": map[string]interface{}{
"CreatedAt": map[string]interface{}{
"type": "date",
},
"GuildID": map[string]interface{}{
"type": "text",
},
"UserID": map[string]interface{}{
"type": "text",
},
"UsedInviteCode": map[string]interface{}{
"type": "text",
},
"VanityInvite": map[string]interface{}{
"type": "text",
},
},
},
},
}
index, err := elastic.CreateIndex("robyul-joins").BodyJson(joinMapping).Do(context.Background())
if err != nil {
panic(err)
}
if !index.Acknowledged {
cache.GetLogger().WithField("module", "migrations").Error("ElasticSearch index not acknowledged")
}
}