ES索引和别名
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ES索引和别名相关的知识,希望对你有一定的参考价值。
参考技术A solution:重建索引,在建新索引时候做字段的迁移,达到修改index/mapping目的
字段迁移
ref: https://www.cnblogs.com/bigbigtree/p/6829625.html
(仅参考)
ref: https://www.jianshu.com/p/a46fc9fce199
index别名 ref: https://www.cnblogs.com/bigbigtree/p/6829625.html
ES建立索引步骤, 1,index 2.mapping 3,别名
1.建立索引
PUT /index_trans_detail
2.建立mapping
POST /index_trans_detail/type_trans_detail/_mapping
"type_trans_detail":
"properties":
"id":
"type": "long"
,
"entId":
"type": "long"
,
"orgId":
"type": "long"
,
"seqno":
"type": "text",
"fielddata": true
,
"transDate":
"type": "date",
"format": "yyyy-MM-dd"
,
"postTatus":
"type": "integer"
,
"ioFlag":
"type": "integer"
,
"depotId":
"type": "long"
,
"depotCode":
"type": "keyword"
,
"depotName":
"type": "text"
,
"depotClassId":
"type": "long"
,
"depotClassCode":
"type": "keyword"
,
"depotClassName":
"type": "text"
,
"orgOrgId":
"type": "long"
,
"orgOrgCode":
"type": "keyword"
,
"orgOrgName":
"type": "text"
,
"orgOrgClassId":
"type": "long"
,
"orgOrgClassCode":
"type": "keyword"
,
"orgOrgClassName":
"type": "text"
,
"balOrgId":
"type": "long"
,
"balOrgCode":
"type": "keyword"
,
"balOrgName":
"type": "text"
,
"transOrgId":
"type": "long"
,
"transOrgCode":
"type": "keyword"
,
"transOrgName":
"type": "text"
,
"transOrgClassId":
"type": "long"
,
"transOrgClassCode":
"type": "keyword"
,
"transOrgClassName":
"type": "text"
,
"transBalOrgId":
"type": "long"
,
"transBalOrgCode":
"type": "keyword"
,
"transBalOrgName":
"type": "text"
,
"transTypeId":
"type": "long"
,
"transType":
"type": "keyword"
,
"transName":
"type": "text"
,
"dutyBillId":
"type": "long"
,
"dutyBillType":
"type": "integer"
,
"dutyBillNo":
"type": "text",
"fielddata": true
,
"sourceId":
"type": "long"
,
"sourceType":
"type": "integer"
,
"sourceNo":
"type": "keyword"
,
"billStatus":
"type": "integer"
,
"headRemark":
"type": "text"
,
"isAllowDel":
"type": "integer"
,
"useOrgId":
"type": "long"
,
"headIoQty":
"type": "double"
,
"headIoAmt":
"type": "double"
,
"headIoCostAmt":
"type": "double"
,
"periodNo":
"type": "text"
,
"externalBillNo":
"type": "text"
,
"externalSysType":
"type": "integer"
,
"useDepId":
"type": "long"
,
"useDepCode":
"type": "keyword"
,
"useDepName":
"type": "text"
,
"usePurpose":
"type": "integer"
,
"transId":
"type": "long"
,
"goodsId":
"type": "long"
,
"goodsCode":
"type": "keyword"
,
"goodsName":
"type": "text"
,
"goodsClassId":
"type": "long"
,
"goodsClassCode":
"type": "keyword"
,
"goodsClassName":
"type": "text"
,
"goodsSpec":
"type": "keyword"
,
"goodsOrigin":
"type": "text"
,
"postFlag":
"type": "integer"
,
"goodsWeight":
"type": "double"
,
"ioQty":
"type": "double"
,
"ioPrice":
"type": "double"
,
"ioAmt":
"type": "double"
,
"unitId":
"type": "long"
,
"unitName":
"type": "text"
,
"unitRate":
"type": "double"
,
"iocostPrice":
"type": "double"
,
"ioCostAmt":
"type": "long"
,
"feeAmt":
"type": "long"
,
"lotId":
"type": "long"
,
"dutyBillDetailId":
"type": "long"
,
"sourceDetailId":
"type": "long"
,
"dutyOrgId":
"type": "long"
,
"postUserId":
"type": "long"
,
"postDateTime":
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
,
"postReturnId":
"type": "long"
,
"errMsg":
"type": "text"
,
"firstPostDatetime":
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
,
"balanceFlag":
"type": "integer"
,
"remark":
"type": "text"
,
"baseQty":
"type": "double"
,
"baseUnitId":
"type": "long"
,
"baseUnitName":
"type": "text"
,
"baseUnitPrice":
"type": "double"
,
"createType":
"type": "integer"
,
"createHeadId":
"type": "long"
,
"invUnitId":
"type": "long"
,
"invUnitCode":
"type": "keyword"
,
"invUnitName":
"type": "text"
,
"invUnitRate":
"type": "double"
,
"invQty":
"type": "double"
,
"invCostPrice":
"type": "double"
,
"discountRate":
"type": "double"
,
"discountTaxRate":
"type": "double"
,
"taxRate":
"type": "double"
,
"taxAmt":
"type": "double"
,
"ioBillStatus":
"type": "integer"
,
"ioBillTime":
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
,
"ioBillQty":
"type": "double"
,
"taxType":
"type": "integer"
,
"isStoBackPrice":
"type": "integer"
,
"stoCostPrice":
"type": "double"
,
"stoCostAmt":
"type": "double"
,
"version":
"type": "integer"
,
"deleted":
"type": "long"
,
"creatorCode":
"type": "keyword"
,
"creatorName":
"type": "text",
"fielddata": true
,
"createdAt":
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
,
"creatorOrgCode":
"type": "keyword",
"index": false
,
"modifierCode":
"type": "keyword",
"index": false
,
"modifierName":
"type": "text"
,
"lastModifiedAt":
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
,
"modifierOrgCode":
"type": "keyword",
"index": false
,
"invTransHeadId":
"type": "long"
,
"handledOrgCode":
"type": "keyword"
,
"handledOrgName":
"type": "text"
,
"createdAtTimestamp":
"type": "date",
"format": "epoch_millis"
,
"transDateTimestamp":
"type": "date",
"format": "epoch_millis"
,
"lastModifiedTimestamp":
"type": "date",
"format": "epoch_millis"
,
"postDateTimeTimestamp":
"type": "date",
"format": "epoch_millis"
,
"ioBillTimeTimestamp":
"type": "date",
"format": "epoch_millis"
,
"firstPostDatetimeTimestamp":
"type": "date",
"format": "epoch_millis"
3.建立别名
PUT /index_trans_detail/_alias/index_trans_detail_alias
以上是关于ES索引和别名的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot Elasticsearch7.6.2实现创建索引删除索引判断索引是否存在获取/添加/删除/更新索引别名单条/批量插入单条/批量更新删除数据递归统计ES聚合的数据