1 : 查看 es 的一些基本状态
- 检查Elasticsearch是否正在运行 : curl http://localhost:9200/
- 集群健康 : GET “localhost:9200/_cat/health?v”
- 查看全部索引 : GET “localhost:9200/_cat/indices?v”
2 : 创建索引
例如创建索引名称 roc_test_index , 索引 type : roc_test_type
1 : 我一般是直接新增一条数据,ID 是1 :
PUT /roc_test_index/roc_test_type/1
{
"id":"1"
}
返回结果 :
{
"_index": "roc_test_index",
"_type": "roc_test_type",
"_id": "1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}
这样的话一个简单的索引就创建好了 ,同时 mapping 也好了
2 : 查看一下新增的索引 :
GET /roc_test_index/roc_test_type/_search
{
"query":{
"match_all":{}
}
}
返回结果 :
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1.0,
"hits": [
{
"_index": "roc_test_index",
"_type": "roc_test_type",
"_id": "1",
"_score": 1.0,
"_source": {
"id": "1"
}
}
]
}
}