kibana-1可视化之创建索引
kibana可视化之创建索引
前提条件:
ES集群正常启动
Kibana正常启动并连接到ES集群
成绩表字段说明:
姓名:name
性别:sex
课程:course
成绩:Score
课程说明:
语文:yuwen
数学:shuxue
英语:yingyu
创建索引,并配置mappings
#name为text类型,用于全文检索(需要安装ik中文分词器插件),可视化统计时text类型的字段是不显示的;name_keyword为keyword类型,用于可视化时聚合。如果仅仅是测试kibana可视化,可以去掉name字段或"analyzer": “ik_max_word”。
PUT chengji
{
"mappings": {
"properties": {
"name": {
"type": "text",
"analyzer": "ik_max_word"
},
"name_keyword": {
"type": "keyword"
},
"sex": {
"type": "keyword"
},
"course": {
"type": "keyword"
},
"Score": {
"type": "integer"
}
}
}
}
执行与结果如图所示:
批量添加测试数据
POST _bulk
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"张三","name_keyword":"张三","sex":"男","course":"语文","Score":76}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"张三","name_keyword":"张三","sex":"男","course":"数学","Score":95}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"张三","name_keyword":"张三","sex":"男","course":"英语","Score":58}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"李四","name_keyword":"李四","sex":"男","course":"语文","Score":68}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"李四","name_keyword":"李四","sex":"男","course":"数学","Score":45}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"李四","name_keyword":"李四","sex":"男","course":"英语","Score":37}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"王五","name_keyword":"王五","sex":"男","course":"语文","Score":81}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"王五","name_keyword":"王五","sex":"男","course":"数学","Score":74}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"王五","name_keyword":"王五","sex":"男","course":"英语","Score":64}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"马六","name_keyword":"马六","sex":"男","course":"语文","Score":69}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"马六","name_keyword":"马六","sex":"男","course":"数学","Score":93}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"马六","name_keyword":"马六","sex":"男","course":"英语","Score":77}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"小丽","name_keyword":"小丽","sex":"女","course":"语文","Score":84}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"小丽","name_keyword":"小丽","sex":"女","course":"数学","Score":61}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"小丽","name_keyword":"小丽","sex":"女","course":"英语","Score":88}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"小梅","name_keyword":"小梅","sex":"女","course":"语文","Score":85}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"小梅","name_keyword":"小梅","sex":"女","course":"数学","Score":78}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"小梅","name_keyword":"小梅","sex":"女","course":"英语","Score":92}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"周美","name_keyword":"周美","sex":"男","course":"语文","Score":96}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"周美","name_keyword":"周美","sex":"男","course":"数学","Score":97}
{"index":{"_index":"chengji","_type":"_doc"}}
{"name":"周美","name_keyword":"周美","sex":"男","course":"英语","Score":93}
执行与结果如图所示:
查询,验证数据添加成功:
POST chengji/_search
{}
查询结果如图所示,说明数据添加成功。