MySQL数据同步至Elasticsearch实例
MySQL数据类型 | Elasticsearch数据类型 | 说明 |
---|---|---|
tinyint | short | 如果源库中的类型为unsigned tinyint,在Elasticsearch中使用integer |
mediumint | integer | -/- |
smallint | short | 如果源库中的类型为unsigned smallint,在Elasticsearch中使用integer |
int | integer | 如果源库中的类型为unsigned int,在Elasticsearch中使用long |
bigint | long | -/- |
Bool Boolean | boolean | -/- |
Decimal DEC | double | 如果decimal后面带小数点,为保证数据一致性,建议Elasticsearch中的数据类型使用text |
double | double | -/- |
float | float | -/- |
Real | double | -/- |
CHAR | text | -/- |
VARCHAR | text | -/- |
longtext | text | -/- |
mediumtext | text | -/- |
tinytext | text | -/- |
blob | binary | -/- |
binary | binary | -/- |
bit | long | 如果bit只有一位,建议Elasticsearch中使用的数据类型为boolean |
Date | date | 在Elaticsearch中的date format为:yyyy-MM-dd。date format的mapping 定义参考Elasticsearch文档。 |
datetime | date | 在Elaticsearch中的date format为:yyyy-MM-dd’T’HH:mm:ss,如果带微秒精度,那么date_format为 yyyy-MM-dd’T’HH:mm:ss.S。date format的mapping 定义参考Elasticsearch文档。 |
timestamp | date | 在Elaticsearch中的date format为:yyyy-MM-dd’T’HH:mm:ss,如果带微秒精度,那么date_format为 yyyy-MM-dd’T’HH:mm:ss.S 。date format的mapping 定义参考Elasticsearch文档。 |
time | date | 在Elaticsearch中的date format为:HH:mm:ss,如果带微秒精度,那么date_format为 HH:mm:ss.S。date format的mapping 定义参考Elasticsearch文档。 |
year | date | 在Elaticsearch中的date format为:yyyy。date format的mapping 定义参考Elasticsearch文档。 |
geometry | geo_shape | -/- |
point | geo_point | -/- |
linestring | geo_shape | -/- |
polygon | geo_shape | -/- |
multipoint | geo_shape | 如果bit只有一位,建议Elasticsearch中使用的数据类型为boolean |
multilinestring | geo_shape | -/- |
multipolygon | geo_shape | -/- |
geometrycollection | geo_shape | -/- |
json | object | 如果bit只有一位,建议Elasticsearch中使用的数据类型为boolean |
参考: