1. ES index use
Create an index:
PUT /my_index
Note: Here PUT /my_index is shorthand, which means RESTful style of PUT access. es服务器ip:9200/my_index
You can use postman to access the test, as shown in the figure:
Get the index:
GET /my_index
Delete the index:
DELETE/my_index
Get indexes in batches:
GET /my_index,study
Get all indexes:
Two ways:
GET /_all
GET /_cat/indices?v
Determine whether the index exists:
HEAD /my_index
Returning 200 Ok means the index exists, as shown in the figure below:
Returning 404 not Found means the index does not exist, as shown in the figure below:
Turn off indexing:
Turning off the index can make the Elasticsearch cluster more efficient when performing maintenance operations on the index. When an index is closed, Elasticsearch will stop updating, searching, and querying the index. This saves system resources and improves the overall performance of the cluster.
POST /my_index/_close
Open the index:
POST /my_index/_open
2. ES mapping use
Create indexes and define mappings
PUT /my_index
{
"mappings": {
"properties": {
"title": {
"type": "text" },
"description": {
"type": "text" }
}
}
}
get mapping
GET /my_index/_mapping
get all maps
two ways
GET /_all/_mapping
GET /_mapping
Update mapping (can only be added, not modified)
PUT /my_index/_mapping
{
"properties": {
"content": {
"type": "keyword" }
}
}