在上一篇博客已经介绍了ElasticSearch相关开发环境的搭建,接下来着手做该环境下索引数据的简单的增删改查操作.
1.结构化创建索引(创建一个名称为school的结构化索引,数据类型定义好的)
PUT school
{
"settings":{
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings":{
"student":{
"properties":{
"name":{
"type":"text"
},
"address":{
"type":"keyword"
},
"age":{
"type":"integer"
},
"date":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss|| yyy-MM-dd||epoch_millis"
}
}
}
}
}
2.指定ID插入数据(相当于插入一条记录到一个数据库表中)
PUT /school/student/1
{