Reindex after mapping

When i do mapping for field then i need do reindex?

PUT /contact
{
      "properties": {
         "perms": {
            "type": "multi_field",
            "fields": {
                "perms": {"type": "string"},
                "original": {"type" : "string", "index" : "not_analyzed"}
            }
         }
      }
   }
}

Yes if you want to be able to search using the new field, then you need to reindex.

May be has ready command for this, or I must make request to elasticsearch for add index?

There is no reindex command.

1 Like

Thank you.

Elasticsearch clients typically offer this e.g. the python one [1]
Note also that the use of aliases [2] eases the transition from one index version to another with no downtime for your users

[1] http://elasticsearch-py.readthedocs.org/en/master/helpers.html#reindex
[2] https://www.elastic.co/guide/en/elasticsearch/guide/current/index-aliases.html

1 Like

If i use alias for example PUT /portal_v1/_alias/portal

when i search by portal, elasticsearch will be use my alias portal_v1?

Right - aliases are an incredibly useful level of indirection an elasticsearch cluster administrator can use to reroute client requests in lots of interesting ways (managing new index versions, querying multiple time-based indexes, filtering index contents for different users....)

in my application i must set type as alias?

$params = [
            'index' => 'portal_v1', // or portal
            'type' => 'contact',
            'size' => 200
        ];

You use the alias name "portal".
From a user's perspective an alias is the same as a concrete index but gives the cluster administrator the option of switching how it is mapped e.g. to portal_v1 or portal_v2 with no client downtime.

when i make new mapping for portal_v2 then i must change all scripts like

$params = [
            'index' => 'portal_v2', 
            'type' => 'contact',
            'size' => 200
        ];