1.基于http
新增:
post http://ip:port/index/type/id
{
"xx":1
}
注:不指定id,则会自动生成一个随机id
更新:
post http://ip:port/index/type/id
{
"xx":2
}
post http://ip:port/index/type/id/_update
{
"doc":{
"xx":2
}
}
put http://ip:port/index/type/id
{
"xx":2
}
post:
带_update更新如果没有任何变更版本号不会变动
不带_update版本会不断更新
put:
版本会不断更新
查询:
get : http://ip:port/index/type/id
批量导入 _bulk
post: http://ip:port/index/type/_bulk
{action:{metadata}} \n 动作以及es元数据
{"xx":"xx"} 请求体
(action: index/put/delete/get)
例:
POST /welless/student1/_bulk
{"index":{"_id":"1"}}
{"name":"welless"}
{"index":{"_id":"2"}}
{"name":"xx"}
2. DSL
GET /bank/_search
{
"query": {
"match_all": {}
},
"sort": [
{
"account_number": {
"order": "asc"
}
}
],
"from": 0,
"size": 5,
"_source": ["balance","firstname"] //指定返回的字段
}
GET /bank/_search
{
"query": {
"match": {
"account_number": "1"
}
}
}