ES has a very important feature - dynamic mapping , which does not need to create an index, type and other information prior to index documents, while the index will automatically index, type, create maps.
So what is mapping it? Mapping is to describe the type of the field, how to analyze, how to make content indexing.
It focuses on the Benpian, ES in the automatic detection of mapping characteristics.
More Reference: Elastisearch knowledge summary
Automatic detection field
When a field for the first time, if not previously been defined mapping, ES will automatically detect the type it possible to meet, and then create a corresponding map.
JSON data |
ES Data Type |
|
Will not add fields |
|
boolean |
floating point number |
double |
integer |
long |
object |
object |
array |
The first relies on a non-null Found |
string |
If by the date test, compared with date If by the numeric test, compared with Number |
The above result is the type of automatic detection, in addition to the basic types listed above, other types such as advanced geo, ip need to manually specify.
Date Automatic detection
Date automatically detect that date_detection is enabled by default, so that they meet the default date format, it can automatically create the type to date
Date format is:
[ "strict_date_optional_time","yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"]
E.g:
$ curl -XPUT localhost:9200/test/test/1 -d '{"create":"2015/11/11"}'
{"_index":"test","_type":"test","_id":"1","_version":1,"created":true}
$ curl -XGET localhost:9200/test/_mapping?pretty
{
"test" : {
"mappings" : {
"test" : {
"properties" : {
"create" : {
"type" : "date",
"format" : "yyyy/MM/dd HH:mm:ss||yyyy/MM/dd"
}
}
}
}
}
}
By modifying dynamic_date_formats
change the date format:
PUT my_index
{
"mappings":{
“my_type":{"dynamic_date_formats":["MM/dd/yyyy"]}
}
}
PUT my_index/my_type/1{"create_date":"09/25/2015"}
Digital automatic detection
Digital automatic detection, i.e. numeric_detection is off by default. Hence the need to manually open:
PUT my_index
{"mappings":{"my_type":{"numeric_detection":true}}}
When performing index operations, if they meet a float, it will automatically create a float
long type is the same:
Reproduced in: https: //my.oschina.net/u/204616/blog/545150