查看先关信息
查看健康状况
通过cat命令可以查看所有能查看的信息
http://localhost:9200/_cat
查看集群健康状况
http://localhost:9200/_cat/health?v
- _cat/health即可查看集群的健康状态
- ?号后面的v, 是用来要求在返回结果找那个返回表头
其中状态值status,有三种不同状态
- Green - everything is good (cluster is fully functional)
- Yellow - all data is available but some replicas are not yet allocated (cluster is fully functional)
- Red - some data is not available for whatever reason (cluster is partially functional)
查看所有索引
http://localhost:9200/_cat/indices?v
创建索引
打开请求工具,这儿使用的是kibana
创建一个索引
PUT /hero?pretty
- 创建一个名为 hero的索引
- pretty要求返回一个漂亮的 json 结果
再查看一下所有索引
GET /_cat/indices?v
索引&查询一个文档
索引一个文档到hero索引中
PUT /hero/_doc/1?pretty
{
“name”: “Ya Suo”
}
- url中的1就是文档的id值,在_doc/后面的指定
从hero索引中获取指定id的文档
curl -X GET “localhost:9200/hero/_doc/1?pretty”
查询所有文档
命令格式:
GET /customer/_search?q=*&sort=name:asc&pretty
举例:
GET /hero/_search
{
“query”: { “match_all”: {} },
“sort”: [
{“name”: “asc” }
]
}