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