传送站:es的批量传输和增删改查
es本质上也是数据库,只不过是分析型数据库,可以快速响应大数据量查询,其中index类似于数据库,type类似于表
那么如何在应用界面端创建index和type呢
首先打开主页,点击复合查询,在红框位置输入对应的index_name和在代码里输入对应的type_name以及相关字段即可创建index_name和type_name
注意:es并不是严格意义上的结构化数据,所以对表结构要求不高,因此title那里可任意设置字段,后续可以根据实际业务自动更改
其实也可以在大数据平台通过数据交换来把数据传进es的同时直接创建index和type
附json创建语句:
{
"settings": {
"index": {
"number_of_shards": "5",
"number_of_replicas": "1"
}
},
"mappings": {
"type_name": {
"properties": {
"created": {
"type": "date"
},
"name": {
"analyzer": "standard",
"boost": 2,
"type": "text"
},
"title": {
"type": "text"
},
"age": {
"type": "integer"
}
}
}
}
}
最后创建完毕后,需要开启index,否则会报index_closed_exception异常,开启方式如下
POST /index_name/_open
返回结果
{ "acknowledged": true, "shards_acknowledged": true }
即为开启正常