现在,启动一个节点和kibana,接下来的一切操作都在kibana
中Dev Tools
下的Console
里完成
创建一篇文档
将小黑的小姨妈的个人信息录入elasticsearch。我们只要输入
PUT t1/doc/
{
"name":"小黑的小姨妈",
"age":
}
PUT表示创建命令。虽然命令可以小写,但是我们推荐大写
{
"_index" : "t1",
"_type" : "doc",
"_id" : "",
"_version" : 1,
"result" : "updated",
"_shards" : {
"total" : ,
"successful" : ,
"failed" :
},
"_seq_no" : ,
"_primary_term" :
}
结果中的result
则是操作类型,现在是created
,表示第一次创建。如果我们再次点击执行该命令,那么result
则会是updated
。我们细心则会发现_version
开始是1,现在你每点击一次就会增加一次。表示第几次更改。
查看所有的索引
GET _cat/indices
查询指定的索引信息
GET t1
返回了t1索引的创建信息
{
"t1" : {
"aliases" : { },
"mappings" : {
"doc" : {
"properties" : {
"age" : {
"type" : "long"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
},
"settings" : {
"index" : {
"creation_date" : "",
"number_of_shards" : "",
"number_of_replicas" : "",
"uuid" : "_7jNW5XATheeK84zKkPwlw",
"version" : {
"created" : ""
},
"provided_name" : "t1"
}
}
}
}
查看文档信息
GET t1/doc/
返回结果
{
"_index" : "t1",
"_type" : "doc",
"_id" : "",
"_version" : 2,
"found" : true,
"_source" : {
"name" : "小黑的小姨妈",
"age" : 18
}
}
查询文档的所有的信息
GET t1/doc/_search
返回信息
{
"took" : 38,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [
{
"_index" : "t1",
"_type" : "doc",
"_id" : "",
"_score" : 1.0,
"_source" : {
"name" : "小黑的二姨妈",
"age" : 16
}
},
{
"_index" : "t1",
"_type" : "doc",
"_id" : "",
"_score" : 1.0,
"_source" : {
"name" : "小黑的小姨妈",
"age" : 18
}
}
]
}
}
查看索引配置信息
GET t1/_settings
返回信息
{
"t1" : {
"settings" : {
"index" : {
"creation_date" : "",
"number_of_shards" : "",
"number_of_replicas" : "",
"uuid" : "WDJy3_KYTjS_ljqr9QIETw",
"version" : {
"created" : ""
},
"provided_name" : "t1"
}
}
}
}
查看映射关系
GET t1/_mappin
返回信息
{
"t1" : {
"mappings" : {
"doc" : {
"properties" : {
"age" : {
"type" : "long"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
删除索引
删除指定文档
DELETE t1/doc/2
删除索引
DELETE t1 返回结果
{
"acknowledged" : true
}