mapping.asciidoc 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. [[mapping]]
  2. = Mapping
  3. [partintro]
  4. --
  5. Mapping is the process of defining how a document, and the fields it contains,
  6. are stored and indexed.
  7. Each document is a collection of fields, which each have their own
  8. <<mapping-types,data type>>. When mapping your data, you create a mapping
  9. definition, which contains a list of fields that are pertinent to the document.
  10. A mapping definition also includes <<mapping-fields,metadata fields>>, like the
  11. `_source` field, which customize how a document's associated metadata is
  12. handled.
  13. Use _dynamic mapping_ and _explicit mapping_ to define your data. Each method
  14. provides different benefits based on where you are in your data journey. For
  15. example, explicitly map fields where you don't want to use the defaults, or to
  16. gain greater control over which fields are created. You can then allow {es} to
  17. add other fields dynamically.
  18. NOTE: Before 7.0.0, the mapping definition included a type name.
  19. {es} 7.0.0 and later no longer accept a _default_ mapping. See <<removal-of-types>>.
  20. .Experiment with mapping options
  21. ****
  22. <<runtime-search-request,Define runtime fields in a search request>> to
  23. experiment with different mapping options, and also fix mistakes in your index
  24. mapping values by overriding values in the mapping during the search request.
  25. ****
  26. [discrete]
  27. [[mapping-dynamic]]
  28. == Dynamic mapping
  29. <<dynamic-field-mapping,Dynamic mapping>> allows you to experiment with
  30. and explore data when you’re just getting started. {es} adds new fields
  31. automatically, just by indexing a document. You can add fields to the top-level
  32. mapping, and to inner <<object,`object`>> and <<nested,`nested`>> fields.
  33. Use <<dynamic-templates,dynamic templates>> to define custom mappings that are
  34. applied to dynamically added fields based on the matching condition.
  35. [discrete]
  36. [[mapping-explicit]]
  37. == Explicit mapping
  38. <<explicit-mapping,Explicit mapping>> allows you to precisely choose how to
  39. define the mapping definition, such as:
  40. * Which string fields should be treated as full text fields.
  41. * Which fields contain numbers, dates, or geolocations.
  42. * The <<mapping-date-format,format>> of date values.
  43. * Custom rules to control the mapping for
  44. <<dynamic-mapping,dynamically added fields>>.
  45. Use <<runtime-mapping-fields,runtime fields>> to make schema changes without
  46. reindexing. You can use runtime fields in conjunction with indexed fields to
  47. balance resource usage and performance. Your index will be smaller, but with
  48. slower search performance.
  49. [discrete]
  50. [[mapping-limit-settings]]
  51. == Settings to prevent mapping explosion
  52. Defining too many fields in an index can lead to a mapping explosion, which can
  53. cause out of memory errors and difficult situations to recover from.
  54. Consider a situation where every new document inserted
  55. introduces new fields, such as with <<dynamic-mapping,dynamic mapping>>.
  56. Each new field is added to the index mapping, which can become a
  57. problem as the mapping grows.
  58. Use the <<mapping-settings-limit,mapping limit settings>> to limit the number
  59. of field mappings (created manually or dynamically) and prevent documents from
  60. causing a mapping explosion.
  61. --
  62. include::mapping/dynamic-mapping.asciidoc[]
  63. include::mapping/explicit-mapping.asciidoc[]
  64. include::mapping/runtime.asciidoc[]
  65. include::mapping/types.asciidoc[]
  66. include::mapping/fields.asciidoc[]
  67. include::mapping/params.asciidoc[]
  68. include::mapping/mapping-settings-limit.asciidoc[]
  69. include::mapping/removal_of_types.asciidoc[]