【主要数据类型】
(1)字符串类型: text, keyword
(2)数字类型:long, integer, short, byte, double, float, half_float, scaled_float
(3)日期:date
(4)日期 纳秒:date_nanos
(5)布尔型:boolean
(6)Binary:binary
(7)Range: integer_range, float_range, long_range, double_range, date_range
【复杂数据类型】
(1)Object: object(单个JSON对象)
(2)Nested: nested (JSON对象数组)
【地理数据类型】
(1)Geo-point: geo_point (纬度/经度积分)
(2)Geo-shape: geo_shape (用于多边形等复杂形状)
【特殊数据类型】
(1)IP: ip (IPv4 和 IPv6 地址)
(2)Completion类型:completion (to provide auto-complete suggestions)
(3)Token count:token_count (to count the number of tokens in a string)
(4)mapper-murmur3:murmur3(to compute hashes of values at index-time and store them in the index)
(5)mapper-annotated-text:annotated-text (to index text containing special markup (typically used for identifying named entities))
(6)Percolator:(Accepts queries from the query-dsl)
(7)Join:(Defines parent/child relation for documents within the same index)
(8)Alias:(Defines an alias to an existing field.)
(9)Rank feature:(Record numeric feature to boost hits at query time.)
(10)Rank features:(Record numeric features to boost hits at query time.)
(11)Dense vector:(Record dense vectors of float values.)
(12)Sparse vector:(Record sparse vectors of float values.)
(13)Search-as-you-type:(A text-like field optimized for queries to implement as-you-type completion)
【数组类型】
在Elasticsearch中,数组不需要一个特定的数据类型,任何字段都默认可以包含一个或多个值,当然,这多个值都必须是字段指定的数据类型。
Multi-fields
Multi-fields 通常用来以不同的方式或目的索引同一个字段。比如,一个字符串类型字段可以同时被映射为 text 类型以用于全文检索、 keyword字段用于排序或聚合。又或者,你可以用standard分析器、english分析器和french分析器来索引同一个 text字段。
【官网解释】
https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html#mapping-types
Field data typesedit
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 keyword, constant_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 typesedit
binary
Binary value encoded as a Base64 string.
boolean
true and false values.
Keywords
The keyword family, including keyword, constant_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 typesedit
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 typesedit
Range
Range types, such as long_range, double_range, date_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 typesedit
aggregate_metric_double
Pre-aggregated metric values.
histogram
Pre-aggregated numerical values in the form of a histogram.
Text search typesedit
text fields
The text family, including text and match_only_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 typesedit
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 typesedit
geo_point
Latitude and longitude points.
geo_shape
Complex shapes, such as polygons.
point
Arbitrary cartesian points.
shape
Arbitrary cartesian geometries.
Other typesedit
percolator
Indexes queries written in Query DSL.
Arraysedit
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-fieldsedit
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.