Elasticsearch Reference [6.2]? Mapping
Refer to the official English document Https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html
Mapping is the process of defining how a document and the fields it contains are stored and indexed, each with a mapping type that determines how the document will be indexed.
Meta-fields
Include _index,_type,_id and _source fields for documents
es field data type :
Https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html
- String type
Text, keyword
- Numeric type
Long, integer, short, Byte, double, float, half_float, scaled_float
- Date type
Date
- Boolean value type
Boolean
- Binary type
Binary
- Range type
Integer_range, Float_range, Long_range, Double_range, Date_range
Array data type (array does not need to define a special type)
"one","two"1,2 ][{"name":"Mary","age":12},{"name":"John","age":10}]
Object data type (JSON nested)
{ "region":"US", "manager":{"age": 30,"name":{ "first":"John", "last": "Smith"} }}
- Geographic data types
Geo-point,geo-shape (more complex, refer to official website documents, generally with geo-point on it)
Special data types
IP (IPV4 and IPV6 addresses)
Completion (auto-complete/search)
Token_count (numeric type, parsing string, number of indexes)
MURMUR3 (the ability to calculate the hash of field values at index time and store them in the index.) Very helpful when running cardinality aggregations on high cardinality and large string fields)
Join (Create parent/child relationships in documents of the same index)
The following is a common parameter type definition & Assignment Demo
type |
parameter Definition |
Assign Value |
Text |
' name ': {' type ': ' Text '} |
"Name": "Zhangsan" |
Keyword |
"Tags": {"type": "Keyword"} |
"Tags": "abc" |
Date |
"Date": {"type": "Date"} |
"Date": "2015-01-01t12:10:30z" |
Long |
"Age": {"type": "Long"} |
"Age": 28 |
Double |
"Score": {"type": "Double"} |
"Score": 98.8 |
Boolean |
"Isgirl": {"type": "Boolean"} |
"Isgirl": True |
Ip |
"Ip_addr": {"type": "IP"} |
"Ip_addr": "192.168.1.1" |
Geo_point |
"Location": {"type": "Geo_point"} |
"Location": {"lat": 40.12, "lon":-71.34} |
Mapping parameters
Https://www.elastic.co/guide/en/elasticsearch/reference/6.2/mapping-params.html
Mapping Parameters |
Notes |
Analyzer |
|
Normalizer |
|
Boost |
|
Coerce |
|
Copy_to |
|
Doc_values |
|
Dynamic |
|
Enabled |
|
Fielddata |
|
Eager_global_ordinals |
|
Format |
|
Ignore_above |
|
Ignore_malformed |
|
Index_options |
|
Index |
|
Fields |
|
Norms |
|
Null_value |
|
Position_increment_gap |
|
Properties |
|
Search_analyzer |
|
Similarity |
|
Store |
|
Term_vector |
|
Elasticsearch Getting Started with (ii) Mapping + field type