mapping.asciidoc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. [[mapping]]
  2. = Mapping
  3. [partintro]
  4. --
  5. Mapping is the process of defining how a document should be mapped to
  6. the Search Engine, including its searchable characteristics such as
  7. which fields are searchable and if/how they are tokenized. In
  8. Elasticsearch, an index may store documents of different "mapping
  9. types". Elasticsearch allows one to associate multiple mapping
  10. definitions for each mapping type.
  11. Explicit mapping is defined on an index/type level. By default, there
  12. isn't a need to define an explicit mapping, since one is automatically
  13. created and registered when a new type or new field is introduced (with
  14. no performance overhead) and have sensible defaults. Only when the
  15. defaults need to be overridden must a mapping definition be provided.
  16. [float]
  17. [[all-mapping-types]]
  18. === Mapping Types
  19. Mapping types are a way to divide the documents in an index into logical
  20. groups. Think of it as tables in a database. Though there is separation
  21. between types, it's not a full separation (all end up as a document
  22. within the same Lucene index).
  23. Field names with the same name across types are highly recommended to
  24. have the same type and same mapping characteristics (analysis settings
  25. for example). There is an effort to allow to explicitly "choose" which
  26. field to use by using type prefix (`my_type.my_field`), but it's not
  27. complete, and there are places where it will never work (like faceting
  28. on the field).
  29. In practice though, this restriction is almost never an issue. The field
  30. name usually ends up being a good indication to its "typeness" (e.g.
  31. "first_name" will always be a string). Note also, that this does not
  32. apply to the cross index case.
  33. [float]
  34. [[mapping-api]]
  35. === Mapping API
  36. To create a mapping, you will need the <<indices-put-mapping,Put Mapping
  37. API>>, or you can add multiple mappings when you <<indices-create-index,create an
  38. index>>.
  39. [float]
  40. [[mapping-settings]]
  41. === Global Settings
  42. The `index.mapping.ignore_malformed` global setting can be set on the
  43. index level to allow to ignore malformed content globally across all
  44. mapping types (malformed content example is trying to index a text string
  45. value as a numeric type).
  46. The `index.mapping.coerce` global setting can be set on the
  47. index level to coerce numeric content globally across all
  48. mapping types (The default setting is true and coercions attempted are
  49. to convert strings with numbers into numeric types and also numeric values
  50. with fractions to any integer/short/long values minus the fraction part).
  51. When the permitted conversions fail in their attempts, the value is considered
  52. malformed and the ignore_malformed setting dictates what will happen next.
  53. --
  54. include::mapping/fields.asciidoc[]
  55. include::mapping/types.asciidoc[]
  56. include::mapping/date-format.asciidoc[]
  57. include::mapping/dynamic-mapping.asciidoc[]
  58. include::mapping/conf-mappings.asciidoc[]
  59. include::mapping/meta.asciidoc[]