2015-12-30 11:50:46 -05:00
|
|
|
[[java-admin-indices-put-mapping]]
|
2018-03-14 17:02:06 -04:00
|
|
|
|
2015-12-30 11:50:46 -05:00
|
|
|
==== Put Mapping
|
|
|
|
|
|
|
|
The PUT mapping API allows you to add a new type while creating an index:
|
|
|
|
|
2018-03-01 04:59:52 -05:00
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
2015-12-30 11:50:46 -05:00
|
|
|
--------------------------------------------------
|
2018-03-01 04:59:52 -05:00
|
|
|
include-tagged::{client-tests}/IndicesDocumentationIT.java[index-with-mapping]
|
2015-12-30 11:50:46 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> <<java-admin-indices-create-index,Creates an index>> called `twitter`
|
|
|
|
<2> It also adds a `tweet` mapping type.
|
|
|
|
|
|
|
|
|
|
|
|
The PUT mapping API also allows to add a new type to an existing index:
|
|
|
|
|
2018-03-14 17:02:06 -04:00
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
2015-12-30 11:50:46 -05:00
|
|
|
--------------------------------------------------
|
2018-03-14 17:02:06 -04:00
|
|
|
include-tagged::{client-tests}/IndicesDocumentationIT.java[putMapping-request-source]
|
2015-12-30 11:50:46 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Puts a mapping on existing index called `twitter`
|
|
|
|
<2> Adds a `user` mapping type.
|
|
|
|
<3> This `user` has a predefined type
|
|
|
|
<4> type can be also provided within the source
|
|
|
|
|
|
|
|
You can use the same API to update an existing mapping:
|
|
|
|
|
2018-03-14 17:02:06 -04:00
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
2015-12-30 11:50:46 -05:00
|
|
|
--------------------------------------------------
|
2018-03-14 17:02:06 -04:00
|
|
|
include-tagged::{client-tests}/IndicesDocumentationIT.java[putMapping-request-source-append]
|
2015-12-30 11:50:46 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
<1> Puts a mapping on existing index called `twitter`
|
|
|
|
<2> Updates the `user` mapping type.
|
|
|
|
<3> This `user` has now a new field `user_name`
|
|
|
|
|
2018-03-14 17:02:06 -04:00
|
|
|
:base-dir!:
|