新建索引
put /products
查询索引
GET products
查看索引的状态
GET /_cat/indices?v
查看指定索引的分片情况
GET /_cat/shards/products?v
删除索引
DELETE /products
创建索引创建映射
PUT /products
{
"settings": {
"number_of_shards": 1 , #指定主分片的数量
"number_of_replicas": 1 #指定副本分片的数量
},
"mappings": {
"properties": {
"id": {
"type": "integer"
},
"title": {
"type": "keyword"
},
"price": {
"type": "double"
},
"create_at": {
"type": "date"
},
"description": {
"type": "text"
}
}
}
}
查看映射
GET /products/_mapping
添加文档
POST /products/_doc/1
{
"id":1,
"title":"可口可乐",
"price":5.00,
"create_at":"2022-04-26",
"description":"可口可乐真不错"
}
查询文档
GET /products/_doc/1
POST /products/_doc/
{
"title":"元气森林",
"price":6.00,
"create_at":"2022-04-25",
"description":"元气森林真好喝"
}
删除文档
DELETE /products/_doc/g1DdZIABSGTOetztD7tw
查询某一索引下的全部文档
GET /products/_search
更新文档
POST /products/_doc/g1DdZIABSGTOetztD7tw/_update
{
"doc" : {"title":"奥利奥"}
}