修改索引类型

# 1. 创建一个中间索引
#创建索引

PUT region_user_request_record2020_07_1/


# 创建Mapping

POST region_user_request_record2020_07_1/main/_mapping
{
    "main": {
      "properties": {
        "body": {
          "type": "text"
        },
        "createTime": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        },
        "env": {
          "type": "keyword"
        },
        "id": {
          "type": "keyword"
        },
        "ip": {
          "type": "keyword"
        },
        "method": {
          "type": "keyword"
        },
        "params": {
          "type": "keyword"
        },
        "requestTime": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        },
        "systemType": {
          "type": "keyword"
        },
        "url": {
          "type": "keyword"
        },
        "userId": {
          "type": "integer"
        }
      }
    }
}


# 2. 向中间索引备份源索引的数据

 POST _reindex
 {
   "source": {
     "index": "region_user_request_record2020_07"
   },
   "dest": {
     "index": "region_user_request_record2020_07_1"
   }
 }

# 3.查询确认数据是否copy过去

GET /region_user_request_record2020_07/_search
{
   "query": {
    "bool": {
      "must": [
        {
          "term": {
            "systemType": {
              "value": "domain_ZJ"
            }
          }
        }
      ]
    }
   },
   "sort": [
     {
       "requestTime": {
         "order": "desc"
       }
     }
   ]
}
GET /region_user_request_record2020_07_1/_search
{
   "query": {
    "bool": {
      "must": [
        {
          "term": {
            "systemType": {
              "value": "domain_ZJ"
            }
          }
        }
      ]
    }
   },
   "sort": [
     {
       "requestTime": {
         "order": "desc"
       }
     }
   ]
}

# 4.删除有问题的索引
# 删除有问题的索引

DELETE region_user_request_record2020_07

# 5.重新创建同名的索引(★字段类型修改正确★)
#创建索引

PUT region_user_request_record2020_07/


# 创建Mapping

POST region_user_request_record2020_07/main/_mapping
{
    "main": {
      "properties": {
        "body": {
          "type": "text"
        },
        "createTime": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        },
        "env": {
          "type": "keyword"
        },
        "id": {
          "type": "keyword"
        },
        "ip": {
          "type": "keyword"
        },
        "method": {
          "type": "keyword"
        },
        "params": {
          "type": "keyword"
        },
        "requestTime": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        },
        "systemType": {
          "type": "keyword"
        },
        "url": {
          "type": "keyword"
        },
        "userId": {
          "type": "integer"
        }
      }
  }
}


# 6. 从中间索引还原到源索引的数据
# 重建索引

 POST _reindex
 {
   "source": {
     "index": "region_user_request_record2020_07_1"
   },
   "dest": {
     "index": "region_user_request_record2020_07"
   }
 }


 
# 7. 删除中间索引

 DELETE region_user_request_record2020_07_1

# 8.给索引加别名

PUT /user_request_record_trip_1/_alias/user_request_record_trip

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值