Reprinted from: https://blog.csdn.net/chengyuqiang/column/info/18392 , ES version 6.3.0
Interpretation core concept
index:
Index (index) is the place to store data specific ElasticSearch, a class is a collection of documents having similar features. ElasticSearch concepts have different meanings in the index, where the index corresponds to a relational database in the database instance. In ElasticSearch index may also be used as a verb, the data represents indexing operations.
Type:
Prior to version 6.0, a ElasticSearch index, can have multiple types; from version 6.0 Start, and a ElasticSearch index, only one type. A type classification is a logical index generally have a document group consisting of the same field. ElasticSearch type of data is equivalent to the concept of relational database tables.
Document:
document is the basis of the logic unit ElasticSearch may be indexed row of data corresponding to the data in a relational database table. ElasticSearch document with JSON format, a plurality of fields, the fields corresponding to the columns in a relational database concepts.
Fragmentation:
when the large amount of data storage space requirements, the index exceeds the limit of disk capacity of a single node, a single node or a slower processing speed. To solve these problems, the data index elasticsearch be cut into a plurality of fragments (Shard), a portion of the data piece stored for each index, distributed over different nodes. When you need to query the index, ElasticSearch send a query to each relevant fragment, after the merger query results, this process is transparent to the application ElasticSearch, user perception of the existence of the fragmentation. A certain slice index specified, no modification.
Copy:
In fact, the full name of the master slice slice, referred to as fragmentation. Relative to the primary slice is a copy of copy is one or more duplicate version of the master slice (or copy), the duplicate version (the copy) can be referred to as a copy fragments can be directly called copy. When the master slice is lost, a copy of the cluster can be upgraded to the new master slice.
Create an index:
(1) the simple way
PUT test
return
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "test"
}
(2) the index name can not include uppercase letters
PUT Test
return
{
"error": {
"root_cause": [
{
"type": "invalid_index_name_exception",
"reason": "Invalid index name [Test], must be lowercase",
"index_uuid": "_na_",
"index": "Test"
}
],
"type": "invalid_index_name_exception",
"reason": "Invalid index name [Test], must be lowercase",
"index_uuid": "_na_",
"index": "Test"
},
"status": 400
}
(3) create a duplicate
PUT test
return
{
"error": {
"root_cause": [
{
"type": "resource_already_exists_exception",
"reason": "index [test/WC6GvUh1RTm1lKWfSURzTA] already exists",
"index_uuid": "WC6GvUh1RTm1lKWfSURzTA",
"index": "test"
}
],
"type": "resource_already_exists_exception",
"reason": "index [test/WC6GvUh1RTm1lKWfSURzTA] already exists",
"index_uuid": "WC6GvUh1RTm1lKWfSURzTA",
"index": "test"
},
"status": 400
}
(4) specify the parameters
PUT blog
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
}
}
return
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "blog"
}
View index:
(1) Check the configuration of the specified index
GET blog/_settings
return
{
"blog": {
"settings": {
"index": {
"creation_date": "1547090371599",
"number_of_shards": "3",
"number_of_replicas": "1",
"uuid": "xwD2Y5k3TXOyNTJQ2lBitw",
"version": {
"created": "6030099"
},
"provided_name": "blog"
}
}
}
}
(2) View more indexes
GET blog,test/_settings
Return
{
"blog": {
"settings": {
"index": {
"creation_date": "1547090371599",
"number_of_shards": "3",
"number_of_replicas": "1",
"uuid": "xwD2Y5k3TXOyNTJQ2lBitw",
"version": {
"created": "6030099"
},
"provided_name": "blog"
}
}
},
"test": {
"settings": {
"index": {
"creation_date": "1547090207687",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "WC6GvUh1RTm1lKWfSURzTA",
"version": {
"created": "6030099"
},
"provided_name": "test"
}
}
}
}
(3) delete the index
DELETE test
return
{
"acknowledged": true
}
The opening and closing of the index
(1) Index Close
POST blog/_close
return
{
"acknowledged": true
}