简体   繁体   中英

How to change existing mapping in ElasticSearch using php?

my current mapping looks like this:

array(1) {
  ["profile_index"]=>
  array(1) {
    ["mappings"]=>
    array(1) {
      ["profile"]=>
      array(1) {
        ["properties"]=>
        array(19) {
          ["AboutMe"]=>
          array(1) {
            ["type"]=>
            string(6) "string"
          }
          ["Name"]=>
          array(1) {
            ["type"]=>
            string(6) "string"
          }
          ["IDProfile"]=>
          array(1) {
            ["type"]=>
            string(6) "string"
          }
        }
      }
    }
  }
}

I want to change the type of IDProfile to integer. this:

$mapParams['index'] = 'profile_index';
$mapParams['type'] = 'profile';
$mapParams["body"]['profile'] = array("properties"=>array("A2_IDProfile"=>array("type"=>"integer")));
$client->indices()->putMapping($mapParams);

and variations of it doesn't work.

Any suggestions?

PS i'm using the official php clinet

You cannot change the index type without reindexing. For a solution check https://www.elastic.co/blog/changing-mapping-with-zero-downtime

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM