put_mapping.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. --
  2. :api: put-mapping
  3. :request: PutMappingRequest
  4. :response: PutMappingResponse
  5. --
  6. [id="{upid}-{api}"]
  7. === Update mapping API
  8. Adds new fields to an existing data stream or index. You can also use the API to
  9. change the search settings of existing fields.
  10. [id="{upid}-{api}-request"]
  11. ==== Request
  12. A +{request}+ requires an `index` argument:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests-file}[{api}-request]
  16. --------------------------------------------------
  17. <1> The index to add the mapping to
  18. ==== Mapping source
  19. A description of the fields to create on the mapping; if not defined, the mapping will default to empty.
  20. ["source","java",subs="attributes,callouts,macros"]
  21. --------------------------------------------------
  22. include-tagged::{doc-tests-file}[{api}-request-source]
  23. --------------------------------------------------
  24. <1> Mapping source provided as a `String`
  25. ==== Providing the mapping source
  26. The mapping source can be provided in different ways in addition to
  27. the `String` example shown above:
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests-file}[{api}-map]
  31. --------------------------------------------------
  32. <1> Mapping source provided as a `Map` which gets automatically converted
  33. to JSON format
  34. ["source","java",subs="attributes,callouts,macros"]
  35. --------------------------------------------------
  36. include-tagged::{doc-tests-file}[{api}-xcontent]
  37. --------------------------------------------------
  38. <1> Mapping source provided as an `XContentBuilder` object, the Elasticsearch
  39. built-in helpers to generate JSON content
  40. ==== Optional arguments
  41. The following arguments can optionally be provided:
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests-file}[{api}-request-timeout]
  45. --------------------------------------------------
  46. <1> Timeout to wait for the all the nodes to acknowledge the index creation as a `TimeValue`
  47. ["source","java",subs="attributes,callouts,macros"]
  48. --------------------------------------------------
  49. include-tagged::{doc-tests-file}[{api}-request-masterTimeout]
  50. --------------------------------------------------
  51. <1> Timeout to connect to the master node as a `TimeValue`
  52. include::../execution.asciidoc[]
  53. [id="{upid}-{api}-response"]
  54. ==== Response
  55. The returned +{response}+ allows to retrieve information about the executed
  56. operation as follows:
  57. ["source","java",subs="attributes,callouts,macros"]
  58. --------------------------------------------------
  59. include-tagged::{doc-tests-file}[{api}-response]
  60. --------------------------------------------------
  61. <1> Indicates whether all of the nodes have acknowledged the request