其他分享
首页 > 其他分享> > es使用之,更改index的数据类型,并保留原有数据

es使用之,更改index的数据类型,并保留原有数据

作者:互联网

文章目录

一、创建新的 index

curl -XPUT “http://localhost:9200/fe_error_2021” -H ‘Content-Type: application/json’ -d ‘{“mappings”:{“fe-error”:{“properties”:{“logType”:{“type”:“keyword”},“col”:{“type”:“keyword”},“country”:{“type”:“keyword”},“appVersion”:{“type”:“keyword”},“screenWidth”:{“type”:“long”},“sourceFileName”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“errorType”:{“type”:“keyword”},“line”:{“type”:“keyword”},“logTimeMillis”:{“type”:“long”},“sourceSymbolName”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“appInfo”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“source”:{“type”:“keyword”},“browserFingerprint”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“effectiveNetStatus”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“browserType”:{“type”:“keyword”},“receiveTimeMillis”:{“type”:“long”},“sourceLine”:{“type”:“integer”},“cityName”:{“type”:“keyword”},“province”:{“type”:“keyword”},“resourceUrl”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“requestUrl”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“appId”:{“type”:“keyword”},“browserVersion”:{“type”:“keyword”},“eventTime”:{“format”:“yyyy-MM-dd HH:mm:ss.SSS”,“type”:“date”},“preUrl”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“browserName”:{“type”:“keyword”},“browserDeviceType”:{“type”:“keyword”},“httpCode”:{“type”:“integer”},“errorTypeContent”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“feUVId”:{“type”:“keyword”},“sourceColumn”:{“type”:“integer”},“devId”:{“type”:“keyword”},“editInfo”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“eventId”:{“type”:“keyword”},“method”:{“type”:“keyword”},“ip”:{“type”:“keyword”},“screenHeight”:{“type”:“long”},“browserDeviceName”:{“type”:“keyword”},“userAgent”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“netStatus”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“url”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“stackInfo”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“receiveTime”:{“format”:“yyyy-MM-dd HH:mm:ss.SSS”,“type”:“date”},“totalHits”:{“type”:“long”},“feUserId”:{“type”:“keyword”},“resourceType”:{“type”:“keyword”},“status”:{“type”:“long”}}}}}’

二、导入数据

curl -XPOST “http://localhost:9200/_reindex” -H ‘Content-Type: application/json’ -d

三、删除 旧的 index

curl -XDELETE “http://localhost:9200/fe_error_2020”

四、创建新的 同名 index

‘{“mappings”:{“fe-error”:{“properties”:{“logType”:{“type”:“keyword”},“col”:{“type”:“keyword”},“country”:{“type”:“keyword”},“appVersion”:{“type”:“keyword”},“screenWidth”:{“type”:“long”},“sourceFileName”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“errorType”:{“type”:“keyword”},“line”:{“type”:“keyword”},“logTimeMillis”:{“type”:“long”},“sourceSymbolName”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“appInfo”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“source”:{“type”:“keyword”},“browserFingerprint”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“effectiveNetStatus”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“browserType”:{“type”:“keyword”},“receiveTimeMillis”:{“type”:“long”},“sourceLine”:{“type”:“integer”},“cityName”:{“type”:“keyword”},“province”:{“type”:“keyword”},“resourceUrl”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“requestUrl”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“appId”:{“type”:“keyword”},“browserVersion”:{“type”:“keyword”},“eventTime”:{“format”:“yyyy-MM-dd HH:mm:ss.SSS”,“type”:“date”},“preUrl”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“browserName”:{“type”:“keyword”},“browserDeviceType”:{“type”:“keyword”},“httpCode”:{“type”:“integer”},“errorTypeContent”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“feUVId”:{“type”:“keyword”},“sourceColumn”:{“type”:“integer”},“devId”:{“type”:“keyword”},“editInfo”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“eventId”:{“type”:“keyword”},“method”:{“type”:“keyword”},“ip”:{“type”:“keyword”},“screenHeight”:{“type”:“long”},“browserDeviceName”:{“type”:“keyword”},“userAgent”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“netStatus”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“url”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“stackInfo”:{“type”:“text”,“fields”:{“keyword”:{“ignore_above”:256,“type”:“keyword”}}},“receiveTime”:{“format”:“yyyy-MM-dd HH:mm:ss.SSS”,“type”:“date”},“totalHits”:{“type”:“long”},“feUserId”:{“type”:“keyword”},“resourceType”:{“type”:“keyword”},“status”:{“type”:“long”}}}}}’

五、导入旧数据 到 新建的 同名index

curl -XPOST “http://localhost:9200/_reindex” -H ‘Content-Type: application/json’ -d ‘{“source”:{“index”:“fe_error_2021”},“dest”:{“index”:“fe_error_2020”}}’

六、删除过渡数据的index

curl -XDELETE “http://localhost:9200/fe_error_2021”

标签:index,keyword,text,数据类型,ignore,above,fields,type,es
来源: https://blog.csdn.net/dabai521/article/details/117386025