Mapping and parsing (mapping and analysis)

Source: Internet
Author: User

When we manipulate the data in index, we will find some strange phenomena, some phenomena will break our original expectation: Now there are 12 tweets in index, only one of them tweets contains the date of 2014-09-15, But look at total in the return of the following query statement:

GET/_search?Q= the              # AResults
GET/_search?Q= the- the- the        # AResults!
GET/_search?Q=Date: the- the- the   #1result
GET/_search?Q=Date: the         #0Results!

When the _all field is queried, all tweets are returned, and no results are returned when the _date field is queried for the year, what is the reason for this? Why are search results different in _all or date fields?

Presumably this is because the data stored in the _all field is different from the way it is stored in the Date field. Now look at how ES parses the document structure and mapipng the tweet request in the GB index:

/ GB / _mapping / Tweet

The returned results are as follows:

{
"GB":{
"Mappings":{
"tweet":{
"Properties":{
"Date":{
"Type":"Date",
"Format":"Dateoptionaltime"
},
"Name":{
"Type":"string"
},
"tweet":{
"Type":"string"
},
"user_id":{
"Type":"Long"
}
}
}
}
}
}

ES has automatically generated a mapping for us, according to which the mapping,es can guess the type of the field. The response message shows that the date field is considered to be a date type. The _all field is not mentioned here because he is a default field, and we know that the type of _all is string.

Therefore, the storage of the date Type field and the String Type field is different, which results in a different search result. It's not a fuss, you might want to specify the exact type of each field--string,numbers,booleans,dates--these are slightly different when stored.

The biggest difference now is how the field's exact values are rendered and how the full text is rendered. This difference is very important, this is the search engine and other database differences.

Original: http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/mapping-analysis.html

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.