1. Quickly check the cluster health status: GET /_cat/health? V. The cluster health status can be green, yellow, or red

Green: The primary shard and replica shard of each index are active

Yellow: The primary shard of each index is in active state, but some Replica shards are not in active state

Red: Not all index primary shards are active. Some index data is missing

Index: GET /_cat/indices v

3. Simple index operations

Create index: PUT /test_index? pretty

DELETE index: DELETE /test_index? pretty

4. CRUD of example goods

1. Add new products, add new documents and build indexes

Syntax: PUT /index/type/id {json data}

 PUT /test_index2/product/1

       {

“name” : “gaolujie yagao”,

“desc” :  “gaoxiao meibai”,

“price” :  30,

“producer” :      “gaolujie producer”,

“tags”: [ “meibai”, “fangzhu” ]

}

Es will automatically set up index and type, which need not be set up in advance, and ES will set up inverted index for each document field by default, so that it can be searched

2. Query products and retrieve documents

Syntax: GET /index/type/ ID

GET /test_index2/product/1

3. Update products and replace documents

PUT /test_index2/product/1

{

“name” : “jiaqiangban gaolujie yagao”,

“desc” :  “gaoxiao meibai”,

“price” :  30,

“producer” :      “gaolujie producer”,

“tags”: [ “meibai”, “fangzhu” ]

}

A drawback of this method is that the document must carry all the fields before it can be modified. If only the modified name is written, then {} contains the name and no other fields

4. Update products and documents

POST /test_index2/product/1/_update

{

“doc”: {

“name”: “jiaqiangban gaolujie yagao”

}

}

5. Delete the document

DELETE /test_index2/product/1