2013-08-28 19:24:34 -04:00
|
|
|
[[indices-put-mapping]]
|
|
|
|
== Put Mapping
|
|
|
|
|
|
|
|
The put mapping API allows to register specific mapping definition for a
|
|
|
|
specific type.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
$ curl -XPUT 'http://localhost:9200/twitter/tweet/_mapping' -d '
|
|
|
|
{
|
|
|
|
"tweet" : {
|
|
|
|
"properties" : {
|
2013-11-07 10:56:59 -05:00
|
|
|
"message" : {"type" : "string", "store" : true }
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
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,mapping>> section.
|
|
|
|
|
|
|
|
[float]
|
2013-09-25 12:17:40 -04:00
|
|
|
[[merging-conflicts]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Merging & Conflicts
|
|
|
|
|
|
|
|
When 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
|
2013-12-27 20:05:31 -05:00
|
|
|
type mapping can be upgraded by specifying multi fields on a core type.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
[float]
|
2013-09-30 17:32:00 -04:00
|
|
|
[[put-mapping-multi-index]]
|
2013-08-28 19:24:34 -04:00
|
|
|
=== Multi Index
|
|
|
|
|
|
|
|
The put mapping API can be applied to more than one index with a single
|
|
|
|
call, or even on `_all` the indices.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
$ curl -XPUT 'http://localhost:9200/kimchy,elasticsearch/tweet/_mapping' -d '
|
|
|
|
{
|
|
|
|
"tweet" : {
|
|
|
|
"properties" : {
|
2013-11-07 10:56:59 -05:00
|
|
|
"message" : {"type" : "string", "store" : true }
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'
|
|
|
|
--------------------------------------------------
|
Make PUT and DELETE consistent for _mapping, _alias and _warmer
See issue #4071
PUT options for _mapping:
Single type can now be added with
`[PUT|POST] {index|_all|*|regex|blank}/[_mapping|_mappings]/type`
and
`[PUT|POST] {index|_all|*|regex|blank}/type/[_mapping|_mappings]`
PUT options for _warmer:
PUT with a single warmer can now be done with
`[PUT|POST] {index|_all|*|prefix*|blank}/{type|_all|*|prefix*|blank}/[_warmer|_warmers]/warmer_name`
PUT options for _alias:
Single alias can now be PUT with
`[PUT|POST] {index|_all|*|prefix*|blank}/[_alias|_aliases]/alias`
DELETE options _mapping:
Several mappings can be deleted at once by defining several indices and types with
`[DELETE] /{index}/{type}`
`[DELETE] /{index}/{type}/_mapping`
`[DELETE] /{index}/_mapping/{type}`
where
`index= * | _all | glob pattern | name1, name2, …`
`type= * | _all | glob pattern | name1, name2, …`
Alternatively, the keyword `_mapings` can be used.
DELETE options for _warmer:
Several warmers can be deleted at once by defining several indices and names with
`[DELETE] /{index}/_warmer/{type}`
where
`index= * | _all | glob pattern | name1, name2, …`
`type= * | _all | glob pattern | name1, name2, …`
Alternatively, the keyword `_warmers` can be used.
DELETE options for _alias:
Several aliases can be deleted at once by defining several indices and names with
`[DELETE] /{index}/_alias/{type}`
where
`index= * | _all | glob pattern | name1, name2, …`
`type= * | _all | glob pattern | name1, name2, …`
Alternatively, the keyword `_aliases` can be used.
2014-01-08 04:34:48 -05:00
|
|
|
|
|
|
|
All options:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
PUT /{index}/_mapping/{type}
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
where
|
|
|
|
|
|
|
|
[horizontal]
|
|
|
|
`{index}`:: `blank | * | _all | glob pattern | name1, name2, …`
|
|
|
|
|
|
|
|
`{type}`:: 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`.
|
|
|
|
The uri `PUT /{index}/{type}/_mapping` is still supported for backwardscompatibility.
|