|
|
|
@ -35,10 +35,10 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//要同步的索引名称,也就是表名称
|
|
|
|
|
indexName := "user_teacher_org"
|
|
|
|
|
indexName := "user_student"
|
|
|
|
|
//取所有
|
|
|
|
|
CTX := context.Background()
|
|
|
|
|
result, err := esClient.Scroll().Index(indexName).Size(10).Do(CTX)
|
|
|
|
|
result, err := esClient.Scroll().Index(indexName).Size(100).Do(CTX)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
@ -50,7 +50,7 @@ func main() {
|
|
|
|
|
//如果是第一次的话而且表不存在的情况下,重新创建表结构
|
|
|
|
|
m := make(map[string]interface{})
|
|
|
|
|
json.Unmarshal([]byte(value.String()), &m)
|
|
|
|
|
if len(m) > 0 && i == 0 {
|
|
|
|
|
if len(m) > 0 && i == len(result.Hits.Hits)-1 {
|
|
|
|
|
addFieldData(indexName, m)
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
@ -83,8 +83,8 @@ func addFieldData(tableName string, m map[string]interface{}) {
|
|
|
|
|
model.FieldLength = 128
|
|
|
|
|
model.DecimalPointLength = 0
|
|
|
|
|
}
|
|
|
|
|
_,err:=db.Insert(model)
|
|
|
|
|
if err!=nil{
|
|
|
|
|
_, err := db.Insert(model)
|
|
|
|
|
if err != nil {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|