types.asciidoc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. [[mapping-types]]
  2. == Field data types
  3. Each field has a _field data type_, or _field type_. This type indicates the
  4. kind of data the field contains, such as strings or boolean values, and its
  5. intended use. For example, you can index strings to both `text` and `keyword`
  6. fields. However, `text` field values are <<analysis,analyzed>> for full-text
  7. search while `keyword` strings are left as-is for filtering and sorting.
  8. Field types are grouped by _family_. Types in the same family support the same
  9. search functionality but may have different space usage or performance
  10. characteristics.
  11. Currently, the only type family is `keyword`, which consists of the `keyword`,
  12. `constant_keyword`, and `wildcard` field types. Other type families have only a
  13. single field type. For example, the `boolean` type family consists of one field
  14. type: `boolean`.
  15. [discrete]
  16. [[_core_datatypes]]
  17. ==== Common types
  18. <<binary,`binary`>>:: Binary value encoded as a Base64 string.
  19. <<boolean,`boolean`>>:: `true` and `false` values.
  20. <<keyword, Keywords>>:: The keyword family, including `keyword`, `constant_keyword`,
  21. and `wildcard`.
  22. <<number,Numbers>>:: Numeric types, such as `long` and `double`, used to
  23. express amounts.
  24. Dates:: Date types, including <<date,`date`>> and
  25. <<date_nanos,`date_nanos`>>.
  26. <<field-alias,`alias`>>:: Defines an alias for an existing field.
  27. [discrete]
  28. [[object-types]]
  29. ==== Objects and relational types
  30. <<object,`object`>>:: A JSON object.
  31. <<flattened,`flattened`>>:: An entire JSON object as a single field value.
  32. <<nested,`nested`>>:: A JSON object that preserves the relationship
  33. between its subfields.
  34. <<parent-join,`join`>>:: Defines a parent/child relationship for documents
  35. in the same index.
  36. [discrete]
  37. [[structured-data-types]]
  38. ==== Structured data types
  39. <<range,Range>>:: Range types, such as `long_range`, `double_range`,
  40. `date_range`, and `ip_range`.
  41. <<ip,`ip`>>:: IPv4 and IPv6 addresses.
  42. <<version,`version`>>:: Software versions. Supports https://semver.org/[Semantic Versioning]
  43. precedence rules.
  44. {plugins}/mapper-murmur3.html[`murmur3`]:: Compute and stores hashes of
  45. values.
  46. [discrete]
  47. [[aggregated-data-types]]
  48. ==== Aggregate data types
  49. <<aggregate-metric-double,`aggregate_metric_double`>>:: Pre-aggregated metric values.
  50. <<histogram,`histogram`>>:: Pre-aggregated numerical values in the form of a histogram.
  51. [discrete]
  52. [[text-search-types]]
  53. ==== Text search types
  54. <<text,`text` fields>>:: The text family, including `text` and `match_only_text`.
  55. Analyzed, unstructured text.
  56. {plugins}/mapper-annotated-text.html[`annotated-text`]:: Text containing special
  57. markup. Used for identifying named entities.
  58. <<completion-suggester,`completion`>>:: Used for auto-complete suggestions.
  59. <<search-as-you-type,`search_as_you_type`>>:: `text`-like type for
  60. as-you-type completion.
  61. <<token-count,`token_count`>>:: A count of tokens in a text.
  62. [discrete]
  63. [[document-ranking-types]]
  64. ==== Document ranking types
  65. <<dense-vector,`dense_vector`>>:: Records dense vectors of float values.
  66. <<rank-feature,`rank_feature`>>:: Records a numeric feature to boost hits at
  67. query time.
  68. <<rank-features,`rank_features`>>:: Records numeric features to boost hits at
  69. query time.
  70. [discrete]
  71. [[spatial_datatypes]]
  72. ==== Spatial data types
  73. <<geo-point,`geo_point`>>:: Latitude and longitude points.
  74. <<geo-shape,`geo_shape`>>:: Complex shapes, such as polygons.
  75. <<point,`point`>>:: Arbitrary cartesian points.
  76. <<shape,`shape`>>:: Arbitrary cartesian geometries.
  77. [discrete]
  78. [[other-types]]
  79. ==== Other types
  80. <<percolator,`percolator`>>:: Indexes queries written in <<query-dsl,Query DSL>>.
  81. [discrete]
  82. [[types-array-handling]]
  83. === Arrays
  84. In {es}, arrays do not require a dedicated field data type. Any field can contain
  85. zero or more values by default, however, all values in the array must be of the
  86. same field type. See <<array>>.
  87. [discrete]
  88. [[types-multi-fields]]
  89. === Multi-fields
  90. It is often useful to index the same field in different ways for different
  91. purposes. For instance, a `string` field could be mapped as
  92. a `text` field for full-text search, and as a `keyword` field for
  93. sorting or aggregations. Alternatively, you could index a text field with
  94. the <<analysis-standard-analyzer,`standard` analyzer>>, the
  95. <<english-analyzer,`english`>> analyzer, and the
  96. <<french-analyzer,`french` analyzer>>.
  97. This is the purpose of _multi-fields_. Most field types support multi-fields
  98. via the <<multi-fields>> parameter.
  99. include::types/aggregate-metric-double.asciidoc[]
  100. include::types/alias.asciidoc[]
  101. include::types/array.asciidoc[]
  102. include::types/binary.asciidoc[]
  103. include::types/boolean.asciidoc[]
  104. include::types/date.asciidoc[]
  105. include::types/date_nanos.asciidoc[]
  106. include::types/dense-vector.asciidoc[]
  107. include::types/flattened.asciidoc[]
  108. include::types/geo-point.asciidoc[]
  109. include::types/geo-shape.asciidoc[]
  110. include::types/histogram.asciidoc[]
  111. include::types/ip.asciidoc[]
  112. include::types/parent-join.asciidoc[]
  113. include::types/keyword.asciidoc[]
  114. include::types/nested.asciidoc[]
  115. include::types/numeric.asciidoc[]
  116. include::types/object.asciidoc[]
  117. include::types/percolator.asciidoc[]
  118. include::types/point.asciidoc[]
  119. include::types/range.asciidoc[]
  120. include::types/rank-feature.asciidoc[]
  121. include::types/rank-features.asciidoc[]
  122. include::types/search-as-you-type.asciidoc[]
  123. include::types/shape.asciidoc[]
  124. include::types/text.asciidoc[]
  125. include::types/token-count.asciidoc[]
  126. include::types/unsigned_long.asciidoc[]
  127. include::types/version.asciidoc[]