Skip to content
Open
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Although there are some other MySQL rivers for Elasticsearch, like [elasticsearc
## Todo

+ MySQL 8
+ ES 6
+ ES 6 (After verification (version 6.4.2), it is now supported. Delete and update are supported)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em, are you sure we can support ES 6 directly? Seem ES 6 has already removed doc Type?

+ Statistic.

## Donate
Expand Down
2 changes: 2 additions & 0 deletions etc/river.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ id="es_id"
tags="es_tags,list"
# Map column `keywords` to ES with array type
keywords=",list"
# Map column (mysql type varchar(255) "2018-11-20 10:10:10") `time` to ES with date type
time="time,date"

# Filter rule
#
Expand Down
9 changes: 9 additions & 0 deletions river/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,15 @@ func (r *River) getFieldValue(col *schema.TableColumn, fieldType string, value i
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
fieldValue = r.makeReqColumnData(col, time.Unix(v.Int(), 0).Format(mysql.TimeFormat))
}
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use else if col.Type == schema.TYPE_STRING

if col.Type == schema.TYPE_STRING {
col.Type = schema.TYPE_DATETIME
v := r.makeReqColumnData(col, value)
str, _ := v.(string)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch v.(type) {
    case string:
    case []byte:
    default:
}

I think you can check string and []byte here.

stamp, _ := time.ParseInLocation("2006-01-02 03:04:05", str, time.Local)
t := int64(stamp.Unix())
fieldValue = r.makeReqColumnData(col, time.Unix(t, 0).Format(mysql.TimeFormat))
}
}
}

Expand Down