Elasticsearch Dynamic Mapping--automatic detection

Source: Internet
Author: User

There is a very important feature in ES-- dynamic mapping , that is, you do not need to create indexes, types, and so on before indexing a document, and the indexes, types, and mappings are created automatically at the same time.

So what is mapping? Mapping is what describes the types of fields, how to analyze them, how to index them, and so on.

This article focuses on the automatic detection of mappings in ES.

More content reference: Elastisearch Knowledge Summary

Field Auto-detection

When a field first appears, if no mappings have been previously defined, ES automatically detects the types that it might satisfy, and then creates the corresponding mappings.

JSON data

Data types in ES

null

Fields are not added

trueOrfalse

Boolean

Floating point number

Double

Integer

Long

Object

Object

Array

Dependent on the first non-null value

String

If date detection is passed, the date

If numeric detection is passed, number

Above is the result of type automatic detection, in addition to the basic types listed above, other advanced types such as GEO,IP need to be manually specified.

Date Automatic detection

Date automatic detection, that is, Date_detection is on by default, so as long as the default date format, you can automatically create a date type

The format of the date is:

" Strict_date_optional_time ","yyyy/mm/dd HH:mm:ss z| | YYYY/MM/DD Z"]

For example:

$ 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"          }        }      }    }  }}

You can modify the dynamic_date_formats date format by modifying:

PUT my_index{    "mappings": {        "My_type": {  "dynamic_date_formats": ["mm/dd/yyyy"]}    } }put my_index/my_type/1{"create_date":"09/25/ "}
Digital Automatic Detection

Digital Auto-detect, that is, Numeric_detection is off by default. So you need to open it manually:

PUT my_index{"mappings": {"my_type": {" numeric_detection ":True}}}

When the index operation is performed, the float is automatically created

The long type is the same:

Elasticsearch Dynamic Mapping--automatic detection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.