get-mapping.asciidoc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. [[indices-get-mapping]]
  2. == Get Mapping
  3. The get mapping API allows to retrieve mapping definitions for an index or
  4. index/type.
  5. [source,js]
  6. --------------------------------------------------
  7. GET /twitter/_mapping/_doc
  8. --------------------------------------------------
  9. // CONSOLE
  10. // TEST[setup:twitter]
  11. [float]
  12. === Multiple Indices and Types
  13. The get mapping API can be used to get more than one index or type
  14. mapping with a single call. General usage of the API follows the
  15. following syntax: `host:port/{index}/_mapping/{type}` where both
  16. `{index}` and `{type}` can accept a comma-separated list of names. To
  17. get mappings for all indices you can use `_all` for `{index}`. The
  18. following are some examples:
  19. [source,js]
  20. --------------------------------------------------
  21. GET /_mapping/_doc
  22. GET /_all/_mapping/_doc
  23. --------------------------------------------------
  24. // CONSOLE
  25. // TEST[setup:twitter]
  26. If you want to get mappings of all indices and types then the following
  27. two examples are equivalent:
  28. [source,js]
  29. --------------------------------------------------
  30. GET /_all/_mapping
  31. GET /_mapping
  32. --------------------------------------------------
  33. // CONSOLE
  34. // TEST[setup:twitter]
  35. [float]
  36. === Skipping types
  37. Types are scheduled to be fully removed in Elasticsearch 8.0 and will not appear
  38. in requests or responses anymore. You can opt in for this future behaviour by
  39. setting `include_type_name=false` in the request, which will return mappings
  40. directly under `mappings` without keying by the type name.
  41. Here is an example:
  42. [source,js]
  43. --------------------------------------------------
  44. PUT test?include_type_name=false
  45. {
  46. "mappings": {
  47. "properties": {
  48. "foo": {
  49. "type": "keyword"
  50. }
  51. }
  52. }
  53. }
  54. GET test/_mappings?include_type_name=false
  55. --------------------------------------------------
  56. // CONSOLE
  57. which returns
  58. [source,js]
  59. --------------------------------------------------
  60. {
  61. "test": {
  62. "mappings": {
  63. "properties": {
  64. "foo": {
  65. "type": "keyword"
  66. }
  67. }
  68. }
  69. }
  70. }
  71. --------------------------------------------------
  72. // TESTRESPONSE