Reindex after mapping

(mr_max) #1

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"}

(David Pilato) #2

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

(mr_max) #3

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

(David Pilato) #4

There is no reindex command.

(mr_max) #5

Thank you.

(Mark Harwood) #6

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


(mr_max) #7

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

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

(Mark Harwood) #8

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....)

(mr_max) #9

in my application i must set type as alias?

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

(Mark Harwood) #10

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.

(mr_max) #11

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

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

(system) #12