Create index in Elasticsearch and add type definition mapping

Source: Internet
Author: User
Tags mysql in

For the first contact with elasticsearch children's shoes, in order to facilitate the understanding of the Elasticsearch and MySQL in contrast to explain:

The index in ES is the equivalent of MySQL db, a MySQL can have multiple db, similar, an ES cluster can have multiple index.

The type in ES is the equivalent of a table in MySQL, where a db in MySQL can have multiple tables that store one of our data in a table.

The type corresponding to the mapping in Es, which corresponds to the table structure in MySQL, defines the data type of the different fields.

That is, summarize:

When we want to store some of our business data in ES, we need 1 to build a index;2, create a corresponding type in this index, define its data format mapping;3, and then store our data in ES after the first two steps are successful.

1. Establish index

" Localhost:9200/hot_rank_201802?pretty "    # hot_rank_201802 is the index name

2. Build type and build mapping

#hot_rank_201802 is the index name Baidu_hot_search_rank is the type name-D followed by the corresponding MySQL table structureCurl-xput'Localhost:9200/hot_rank_201802/_mapping/baidu_hot_search_rank?pretty'-H'Content-type:application/json'-D'{  "Properties": {    "Long_rank": {        "type":"Long"    },    "Kw_topic": {        "type":"keyword"    },    "Kw_url": {        "type":"keyword"    },    "Kw_mark": {        "type":"keyword"    },    "Long_searchindex": {        "type":"Long"    },    "Date_grabat": {        "type":"Date"    },    "Kw_relatednewsurl": {        "type":"keyword"    },    "Kw_relatedvideourl": {        "type":"keyword"    },    "Kw_relatedimgurl": {        "type":"keyword"    }  }}'

After these two steps, we have successfully established our data table in ES.

Create index in Elasticsearch and add type definition mapping

Related Article

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.