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