首先是json直接的增删该查,在Postman里直接通过Json语句修改ES里的索引
POST 127.0.0.1:9200/people
{
"settings":{
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings":{
"man":{
"properties":{
"name":{
"type":"text"
},
"country":{
"type":"keyword"
},
"age":{
"type":"integer"
},
"date":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
}
增加一行:
'PUT 127.0.0.1:9200/people/man/1
{
"name" : astronaut
"country" : China
"age":20
"date" : 1998-03-20
}
更新:
POST 127.0.0.1:9200/people/man/1/_update
方法1:
{
"script":{
"lang":"painless",
"inline":"ctx._source.age += 10"
}
}
方法2:
{
"script":{
"lang":"painless",
"inline":"ctx._source.age = params.age",
"params":{
"age":100
}
}
}
删除一行数据:
DELETE 127.0.0.1:9200/people/man/1
查找:
POST 127.0.0.1:9200/people/_search
{
"query":{
"match_all":{}
}
}