当前位置:网站首页>Es create a new index database and copy the old index library, practice pro test effective!

Es create a new index database and copy the old index library, practice pro test effective!

2020-11-06 21:40:00 Architects who can drive

Preface : Index library field encountered in project mapping The problem of mapping type mismatch , Need modification mapping Mapping type , So I thought about deleting the old mappings The redesign mappings Field type and copy data !

First step 、 Let's take a look at the old index library settings、mapping structure
GET /intpolicy/_mapping
GET /intpolicy/_settings?pretty
The second step 、 Take a look at the amount of data in the old index database and compare it after copying
GET /intpolicy/_search
The third step 、 Create a new index library   Be careful settings、mapping Do not copy structure errors
PUT intpolicy?include_type_name=false
 {
    "settings" : {
      "index" : {
        "number_of_shards" : "1",
        "provided_name" : "intpolicy",
        "creation_date" : "1578638080477",
        "analysis" : {
          "analyzer" : {
            "numanalyzer" : {
              "pattern" : "|",
              "type" : "pattern"
            }
          }
        },
        "number_of_replicas" : "0",
        "uuid" : "cmouqXBLQiyFAJ5BNii8nw",
        "version" : {
          "created" : "6080599"
        }
      }
    },
    "mappings" : {
      "_doc" : {
        "properties" : {
          "advanceTicketLatest" : {
            "type" : "short"
          },
          "advantageType" : {
            "type" : "keyword"
          },
          "arr" : {
            "type" : "text"
          }
        }
      }
    }
}

The last step Copy the old index database data to the new index library
POST _reindex
{
 "source": {
 "index": "intpolicy2"
 },
 "dest": {
 "index": "intpolicy"
 }
}


 

版权声明
本文为[Architects who can drive]所创,转载请带上原文链接,感谢