put-mapping.asciidoc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. [[indices-put-mapping]]
  2. == Put Mapping
  3. The put mapping API allows to register specific mapping definition for a
  4. specific type.
  5. [source,js]
  6. --------------------------------------------------
  7. $ curl -XPUT 'http://localhost:9200/twitter/_mapping/tweet' -d '
  8. {
  9. "tweet" : {
  10. "properties" : {
  11. "message" : {"type" : "string", "store" : true }
  12. }
  13. }
  14. }
  15. '
  16. --------------------------------------------------
  17. The above example creates a mapping called `tweet` within the `twitter`
  18. index. The mapping simply defines that the `message` field should be
  19. stored (by default, fields are not stored, just indexed) so we can
  20. retrieve it later on using selective loading.
  21. More information on how to define type mappings can be found in the
  22. <<mapping,mapping>> section.
  23. [float]
  24. [[merging-conflicts]]
  25. === Merging & Conflicts
  26. When an existing mapping already exists under the given type, the two
  27. mapping definitions, the one already defined, and the new ones are
  28. merged. If there are conflicts then the update will be rejected.
  29. The definition of conflict is really dependent on the type merged, but
  30. in general, if a different core type is defined, it is considered as a
  31. conflict. New mapping definitions can be added to object types, and core
  32. type mappings can be upgraded by specifying multi fields on a core type.
  33. [float]
  34. [[put-mapping-multi-index]]
  35. === Multi Index
  36. The put mapping API can be applied to more than one index with a single
  37. call, or even on `_all` the indices.
  38. [source,js]
  39. --------------------------------------------------
  40. $ curl -XPUT 'http://localhost:9200/kimchy,elasticsearch/_mapping/tweet' -d '
  41. {
  42. "tweet" : {
  43. "properties" : {
  44. "message" : {"type" : "string", "store" : true }
  45. }
  46. }
  47. }
  48. '
  49. --------------------------------------------------
  50. All options:
  51. [source,js]
  52. --------------------------------------------------
  53. PUT /{index}/_mapping/{type}
  54. --------------------------------------------------
  55. where
  56. [horizontal]
  57. `{index}`:: `blank | * | _all | glob pattern | name1, name2, …`
  58. `{type}`:: Name of the type to add. Must be the name of the type defined in the body.
  59. Instead of `_mapping` you can also use the plural `_mappings`.