Elasticsearch7 Field data types

Each field has a field data type, or field type. This type indicates the kind of data the field contains, such as strings or boolean values, and its intended use. For example, you can index strings to both text and keyword fields. However, text field values are analyzed for full-text search while keyword strings are left as-is for filtering and sorting.

Field types are grouped by family. Types in the same family support the same search functionality but may have different space usage or performance characteristics.

Currently, the only type family is keyword, which consists of the keywordconstant_keyword, and wildcard field types. Other type families have only a single field type. For example, the boolean type family consists of one field type: boolean.

Common types

  • binary: Binary value encoded as a Base64 string.
  • boolean: true and false values.
  • Keywords: The keyword family, including keywordconstant_keyword, and wildcard.
  • Numbers: Numeric types, such as long and double, used to express amounts.
  • Dates: Date types, including date and date_nanos.
  • alias: Defines an alias for an existing field.

Objects and relational types

  • object: A JSON object.
  • flattened: An entire JSON object as a single field value.
  • nested: A JSON object that preserves the relationship between its subfields.
  • join: Defines a parent/child relationship for documents in the same index.

Structured data types

  • Range: Range types, such as long_rangedouble_rangedate_range, and ip_range.
  • ip: IPv4 and IPv6 addresses.
  • version: Software versions. Supports Semantic Versioning precedence rules.
  • murmur3: Compute and stores hashes of values.

Aggregate data types

  • aggregate_metric_double: Pre-aggregated metric values.
  • histogram: Pre-aggregated numerical values in the form of a histogram.

Text search types

  • text: Analyzed, unstructured text.
  • annotated-text: Text containing special markup. Used for identifying named entities.
  • completion: Used for auto-complete suggestions.
  • search_as_you_type: text-like type for as-you-type completion.
  • token_count: A count of tokens in a text.

Document ranking types

  • dense_vector: Records dense vectors of float values.
  • sparse_vector: Records sparse vectors of float values.
  • rank_feature: Records a numeric feature to boost hits at query time.
  • rank_features: Records numeric features to boost hits at query time.

Spatial data types

  • geo_point: Latitude and longitude points.
  • geo_shape: Complex shapes, such as polygons.
  • point: Arbitrary cartesian points.
  • shape: Arbitrary cartesian geometries.

Other types

  • percolator: Indexes queries written in Query DSL.

Arrays

In Elasticsearch, arrays do not require a dedicated field data type. Any field can contain zero or more values by default, however, all values in the array must be of the same field type. See Arrays.

Multi-fields

It is often useful to index the same field in different ways for different purposes. For instance, a string field could be mapped as a text field for full-text search, and as a keyword field for sorting or aggregations. Alternatively, you could index a text field with the standard analyzer, the english analyzer, and the french analyzer.

This is the purpose of multi-fields. Most field types support multi-fields via the fields parameter.

本文为转载文章,贵在分享,版权归原作者及原出处所有,如涉及版权等问题,请及时与我联系。
原文出处:elastic
原文链接:https://www.elastic.co/guide/en/elasticsearch/reference/7.x/mapping-types.html#_core_datatypes

(2)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
兰玉磊兰玉磊
上一篇 2021年4月13日
下一篇 2021年4月24日

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注