https://www.elastic.co/cn/downloads/kibana
https://www.elastic.co/cn/downloads/past-releases#kibana
选择相应的产品和对应的版本:
安装十分简单,直接解压即可,然后运行bin/kibana.bat批处理文件即可,如下图:
运行效果如下:
访问地址:
http://localhost:5601/app/kibana
选择dev tools:
进入操作页面:
PUT tb_hero
{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
}
name | 价格 |
---|---|
number_of_shards | 分片数 |
number_of_replicas | 副本数 |
mappings | 结构化数据设置 下面的一级属性 是自定义的类型 |
properties | 类型的属性设置节点,下面都是属性 |
epoch_millis | 表示时间戳 |
也可以使用默认配置
put tb_hero
执行结果:
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "tb_hero"
}
GET _cat/indices
执行结果:
查看所有索引
GET tb_hero
执行结果:
put /tb_hero/_doc/1
{
"name":"武松",
"age":"33",
"gender":"男",
"work":"打虎"
}
也可不指定id,但需要使用post命令,id会自动生成
POST /tb_hero/_doc
{
"name":"鲁智深",
"age":"40",
"gender":"男",
"work":"拔树"
}
未指定id时的执行结果:
GET /tb_hero/_search
执行结果:
{
"took" : 190,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "tb_hero",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "武松",
"age" : "33",
"gender" : "男",
"work" : "打虎"
}
},
{
"_index" : "tb_hero",
"_type" : "_doc",
"_id" : "VeEjEHoBx-sP55Hp_muF",
"_score" : 1.0,
"_source" : {
"name" : "鲁智深",
"age" : "40",
"gender" : "男",
"work" : "拔树"
}
}
]
}
}
GET /tb_hero/_doc/1
执行结果:
{
"_index" : "tb_hero",
"_type" : "_doc",
"_id" : "1",
"_version" : 1,
"_seq_no" : 0,
"_primary_term" : 1,
"found" : true,
"_source" : {
"name" : "武松",
"age" : "33",
"gender" : "男",
"work" : "打虎"
}
}
PUT /tb_hero/_doc/1
{
"name":"武松",
"age" : "44",
"gender":"男",
"work":"都头"
}
POST /tb_hero/_update/1
{
"doc": {
"age" : "32"
}
}
DELETE /tb_hero/_doc/1
POST /tb_hero/_delete_by_query
{
"query":{
"match":{
"name":"武松"
}
}
}
delete test
执行结果:
{
"acknowledged": true
}
# 查询索引数量
GET _cat/count
# 查询索引的健康情况
GET _cat/health?v
# 查询已经安装的插件
GET _cat/plugins
# 查询有哪些索引
# show databases
GET _cat/indices
GET _cat/indices?v
# 创建索引
# create database db_xxx
PUT /kaoshi
# 删除索引
# drop database db_xxx
DELETE kaoshi
DELETE /yunjisuan
# 创建映射
# create table tb_xxx
POST /kaoshi/_mappings
{
"properties": {
"id": {
"type": "long"
},
"title": {
"type": "text",
"analyzer": "ik_smart"
},
"content": {
"type": "text",
"analyzer": "ik_smart"
}
}
}
# show create table tb_xxx
GET /kaoshi
# insert into tb_xxx() values()
put /kaoshi/_doc/2
{
"id":"2",
"title":"夜宿山寺",
"content":"危楼高百尺"
}
# select * from tb_xxx
GET /kaoshi/_search
GET /kaoshi/_doc/2
GET /kaoshi/_search
{
"query": {
"match": {
"id": "1"
}
}
}
GET _search
{
"query": {
"match_all": {}
}
}
# 查询所有索引
GET _cat/indices
# 创建索引
PUT /shuihu
# 查看索引设置
GET /shuihu/_settings
# 创建映射
PUT /shuihu
{
"mappings": {
"properties":{
"id":{"type":"long"},
"name":{"type":"text","analyzer":"ik_max_word"},
"sex":{"type":"text"},
"age":{"type":"long"}
}
}
}
# 添加文档
put /shuihu/_doc/1
{
"id":1,
"name":"武松",
"age":32,
"sex":"男",
"begood":"打老虎"
}
put /shuihu/_doc/2
{
"id":2,
"name":"鲁智深",
"age":32,
"sex":"男",
"begood":"拔树"
}
# 查询文档
GET /shuihu/_doc/1
# 查询所有文档
GET /shuihu/_doc/_search
{
"query": {
"match_all": {}
}
}
# 修改文档
put /shuihu/_doc/1
{
"id":1,
"name":"武松",
"age":39,
"sex":"男",
"begood":"打老虎"
}
# 删除id为1的文档
DELETE /shuihu/_doc/1
# 条件删除文档
delete /shuihu/_doc/_query
{
"query": {
"match": { "first_name": "zhou"}
}
}
# 删除索引
delete /shuihu
# 删除所有索引
DELETE http://localhost:9200/_all