mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-05 20:48:22 +00:00
411739fe3b
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.
84 lines
2.4 KiB
Plaintext
84 lines
2.4 KiB
Plaintext
[[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" : {
|
|
"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,mapping>> section.
|
|
|
|
[float]
|
|
[[merging-conflicts]]
|
|
=== 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
|
|
type mapping can be upgraded by specifying multi fields on a core type.
|
|
|
|
[float]
|
|
[[put-mapping-multi-index]]
|
|
=== 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" : {
|
|
"message" : {"type" : "string", "store" : true }
|
|
}
|
|
}
|
|
}
|
|
'
|
|
--------------------------------------------------
|
|
|
|
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.
|