38.mapping Small Example

Source: Internet
Author: User

Key points of knowledge

Preliminary Understanding Mapping

One, prepare the data

Insert a few data to let es automatically create an index for US

Put/website/article/1

{

"Post_date": "2017-01-01",

"title": "My first article",

"Content": "This was my first article in this website",

"author_id": 11400

}

Put/website/article/2

{

"Post_date": "2017-01-02",

"title": "My second article",

"Content": "This was my second article in this website",

"author_id": 11400

}

Put/website/article/3

{

"Post_date": "2017-01-03",

"title": "My third article",

"Content": "This was my third article in this website",

"author_id": 11400

}

Second, try a variety of search, and compare search results

get/website/article/_search?q=2017 3 article Results

get/website/article/_search?q=2017-01-01 3 article Results

get/website/article/_search?q=post_date:2017-01-01 1 article Results

get/website/article/_search?q=post_date:2017 1 article Results

third, view the mapping of type

Get/website/_mapping/article

The results of the implementation are as follows:

{

"Website": {

"Mappings": {

"article": {

"Properties": {

"author_id": {

'type ': ' Long '

},

"Content": {

"Type": "Text",

"Fields": {

"keyword": {

"type": "Keyword",

"Ignore_above": 256

}

}

},

"Post_date": {

' Type ': ' Date '

},

"title": {

"Type": "Text",

"Fields": {

"keyword": {

"type": "Keyword",

"Ignore_above": 256

}

}

}

}

}

}

}

}

from the results can be seen es index type A data structure and its associated configuration, The abbreviation is mapping

1 , dynamic mapping index type and type mapping mapping field corresponding data types, and how to set the word breaker

2 , manually-created Mapping, You can also manually create the data before you create it Index and the type , as well type corresponding to the Mapping .

Iv. Why the search results are inconsistent

because es Automatic Setup Mapping the time, for the different Field set up a different Data Type . Different data types, such as word breakers, search, and other behaviors are not the same. So there's a _all field and post_date field search performance is completely different.

38.mapping Small Example

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.