dynamic-mapping.asciidoc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. [[mapping-dynamic-mapping]]
  2. == Dynamic Mapping
  3. Default mappings allow to automatically apply generic mapping definition
  4. to types that do not have mapping pre defined. This is mainly done
  5. thanks to the fact that the
  6. <<mapping-object-type,object mapping>> and
  7. namely the <<mapping-root-object-type,root
  8. object mapping>> allow for schema-less dynamic addition of unmapped
  9. fields.
  10. The default mapping definition is plain mapping definition that is
  11. embedded within the distribution:
  12. [source,js]
  13. --------------------------------------------------
  14. {
  15. "_default_" : {
  16. }
  17. }
  18. --------------------------------------------------
  19. Pretty short, no? Basically, everything is defaulted, especially the
  20. dynamic nature of the root object mapping. The default mapping
  21. definition can be overridden in several manners. The simplest manner is
  22. to simply define a file called `default-mapping.json` and placed it
  23. under the `config` directory (which can be configured to exist in a
  24. different location). It can also be explicitly set using the
  25. `index.mapper.default_mapping_location` setting.
  26. The dynamic creation of mappings for unmapped types can be completely
  27. disabled by setting `index.mapper.dynamic` to `false`.
  28. As an example, here is how we can change the default
  29. <<mapping-date-format,date_formats>> used in the
  30. root and inner object types:
  31. [source,js]
  32. --------------------------------------------------
  33. {
  34. "_default_" : {
  35. "date_formats" : ["yyyy-MM-dd", "dd-MM-yyyy", "date_optional_time"],
  36. }
  37. }
  38. --------------------------------------------------