put-mapping.asciidoc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/tweet/_mapping' -d '
  8. {
  9. "tweet" : {
  10. "properties" : {
  11. "message" : {"type" : "string", "store" : "yes"}
  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. When an existing mapping already exists under the given type, the two
  26. mapping definitions, the one already defined, and the new ones are
  27. merged. The `ignore_conflicts` parameters can be used to control if
  28. conflicts should be ignored or not, by default, it is set to `false`
  29. which means conflicts are *not* ignored.
  30. The definition of conflict is really dependent on the type merged, but
  31. in general, if a different core type is defined, it is considered as a
  32. conflict. New mapping definitions can be added to object types, and core
  33. type mapping can be upgraded to `multi_field` type.
  34. [float]
  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/tweet/_mapping' -d '
  41. {
  42. "tweet" : {
  43. "properties" : {
  44. "message" : {"type" : "string", "store" : "yes"}
  45. }
  46. }
  47. }
  48. '
  49. --------------------------------------------------