WARNING: Version 1.5 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Put Mapping
editPut Mapping
editThe put mapping API allows to register specific mapping definition for a specific type.
$ curl -XPUT 'http://localhost:9200/twitter/_mapping/tweet' -d ' { "tweet" : { "properties" : { "message" : {"type" : "string", "store" : true } } } } '
The above example creates a mapping called tweet
within the twitter
index. The mapping simply defines that the message
field should be
stored (by default, fields are not stored, just indexed) so we can
retrieve it later on using selective loading.
More information on how to define type mappings can be found in the mapping section.
Merging & Conflicts
editWhen an existing mapping already exists under the given type, the two
mapping definitions, the one already defined, and the new ones are
merged. The ignore_conflicts
parameters can be used to control if
conflicts should be ignored or not, by default, it is set to false
which means conflicts are not ignored.
The definition of conflict is really dependent on the type merged, but in general, if a different core type is defined, it is considered as a conflict. New mapping definitions can be added to object types, and core type mappings can be upgraded by specifying multi fields on a core type.
Multi Index
editThe put mapping API can be applied to more than one index with a single
call, or even on _all
the indices.
$ curl -XPUT 'http://localhost:9200/kimchy,elasticsearch/_mapping/tweet' -d ' { "tweet" : { "properties" : { "message" : {"type" : "string", "store" : true } } } } '
All options:
PUT /{index}/_mapping/{type}
where
|
|
|
Name of the type to add. Must be the name of the type defined in the body. |
Instead of _mapping
you can also use the plural _mappings
.