types.asciidoc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 have exactly the
  9. same search behavior but may have different space usage or performance
  10. characteristics.
  11. Currently, there are two type families, `keyword` and `text`. Other type
  12. families have only a single field type. For example, the `boolean` type family
  13. consists of one field type: `boolean`.
  14. [discrete]
  15. [[_core_datatypes]]
  16. ==== Common types
  17. <<binary,`binary`>>:: Binary value encoded as a Base64 string.
  18. <<boolean,`boolean`>>:: `true` and `false` values.
  19. <<keyword, Keywords>>:: The keyword family, including `keyword`, `constant_keyword`,
  20. and `wildcard`.
  21. <<number,Numbers>>:: Numeric types, such as `long` and `double`, used to
  22. express amounts.
  23. Dates:: Date types, including <<date,`date`>> and
  24. <<date_nanos,`date_nanos`>>.
  25. <<field-alias,`alias`>>:: Defines an alias for an existing field.
  26. [discrete]
  27. [[object-types]]
  28. ==== Objects and relational types
  29. <<object,`object`>>:: A JSON object.
  30. <<flattened,`flattened`>>:: An entire JSON object as a single field value.
  31. <<nested,`nested`>>:: A JSON object that preserves the relationship
  32. between its subfields.
  33. <<parent-join,`join`>>:: Defines a parent/child relationship for documents
  34. in the same index.
  35. <<passthrough,`passthrough`>>:: Provides aliases for sub-fields at the same level.
  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. <<semantic-text, `semantic_text`>>:: Used for performing <<semantic-search,semantic search>>.
  62. <<token-count,`token_count`>>:: A count of tokens in a text.
  63. [discrete]
  64. [[document-ranking-types]]
  65. ==== Document ranking types
  66. <<dense-vector,`dense_vector`>>:: Records dense vectors of float values.
  67. <<sparse-vector,`sparse_vector`>>:: Records sparse vectors of float values.
  68. <<rank-feature,`rank_feature`>>:: Records a numeric feature to boost hits at
  69. query time.
  70. <<rank-features,`rank_features`>>:: Records numeric features to boost hits at
  71. query time.
  72. [discrete]
  73. [[spatial_datatypes]]
  74. ==== Spatial data types
  75. <<geo-point,`geo_point`>>:: Latitude and longitude points.
  76. <<geo-shape,`geo_shape`>>:: Complex shapes, such as polygons.
  77. <<point,`point`>>:: Arbitrary cartesian points.
  78. <<shape,`shape`>>:: Arbitrary cartesian geometries.
  79. [discrete]
  80. [[other-types]]
  81. ==== Other types
  82. <<percolator,`percolator`>>:: Indexes queries written in <<query-dsl,Query DSL>>.
  83. [discrete]
  84. [[types-array-handling]]
  85. === Arrays
  86. In {es}, arrays do not require a dedicated field data type. Any field can contain
  87. zero or more values by default, however, all values in the array must be of the
  88. same field type. See <<array>>.
  89. [discrete]
  90. [[types-multi-fields]]
  91. === Multi-fields
  92. It is often useful to index the same field in different ways for different
  93. purposes. For instance, a `string` field could be mapped as
  94. a `text` field for full-text search, and as a `keyword` field for
  95. sorting or aggregations. Alternatively, you could index a text field with
  96. the <<analysis-standard-analyzer,`standard` analyzer>>, the
  97. <<english-analyzer,`english`>> analyzer, and the
  98. <<french-analyzer,`french` analyzer>>.
  99. This is the purpose of _multi-fields_. Most field types support multi-fields
  100. via the <<multi-fields>> parameter.
  101. include::types/aggregate-metric-double.asciidoc[]
  102. include::types/alias.asciidoc[]
  103. include::types/array.asciidoc[]
  104. include::types/binary.asciidoc[]
  105. include::types/boolean.asciidoc[]
  106. include::types/completion.asciidoc[]
  107. include::types/date.asciidoc[]
  108. include::types/date_nanos.asciidoc[]
  109. include::types/dense-vector.asciidoc[]
  110. include::types/flattened.asciidoc[]
  111. include::types/geo-point.asciidoc[]
  112. include::types/geo-shape.asciidoc[]
  113. include::types/histogram.asciidoc[]
  114. include::types/ip.asciidoc[]
  115. include::types/parent-join.asciidoc[]
  116. include::types/keyword.asciidoc[]
  117. include::types/nested.asciidoc[]
  118. include::types/numeric.asciidoc[]
  119. include::types/object.asciidoc[]
  120. include::types/passthrough.asciidoc[]
  121. include::types/percolator.asciidoc[]
  122. include::types/point.asciidoc[]
  123. include::types/range.asciidoc[]
  124. include::types/rank-feature.asciidoc[]
  125. include::types/rank-features.asciidoc[]
  126. include::types/search-as-you-type.asciidoc[]
  127. include::types/semantic-text.asciidoc[]
  128. include::types/shape.asciidoc[]
  129. include::types/sparse-vector.asciidoc[]
  130. include::types/text.asciidoc[]
  131. include::types/token-count.asciidoc[]
  132. include::types/unsigned_long.asciidoc[]
  133. include::types/version.asciidoc[]