Elasticsearch | 03 基本语句和SQL支持
POST /account/_bulk
{"index":{"_id":"1"}}
{"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
{"index":{"_id":"6"}}
{"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}
POST /_sql?format=txt
{
"query": "SELECT account_number,firstname ,lastname, age, balance, address FROM account LIMIT 10"
}
# 查看健康状态
GET /_cat/health?format=json
# 查看节点信息
GET /_cat/nodes?format=json
# 创建index
PUT /test
# 删除index及数据
DELETE /test
DELETE /es_event
DELETE /account
DELETE /book-index
# 查看index列表
GET /_cat/indices?format=json
# 新增/覆盖数据
PUT /test/_doc/1
{
"name": "jack word",
"age":22
}
# 查询数据
GET /test/_doc/1
# 删除数据
DELETE /test/_doc/1
# 新增/更新某字段数据
POST /test/_doc/1/_update
{
"doc":{"nick": "John"}
}
# 查询index的mapping
GET /test/_mapping
# 查询index分页数据
GET /test/_search
{
"query": { "match_all": {} },
"from": 0,
"size": 2
}
# 排序
GET /test/_search
{
"query": { "match_all": {} },
"sort": [
{ "age": "asc" }
],
"from":0,
"size":10
}
# 过滤字段
GET /test/_search
{
"query": { "match_all": {} },
"_source": ["age", "name"]
}
# 批量创建
POST /customer/_doc/_bulk
{"index":{"_id":"3"}}
{"name": "John Doe3" }
{"index":{"_id":"4"}}
{"name": "Jane Doe4" }
# 批量更新、删除
POST /customer/_doc/_bulk
{"update":{"_id":"1"}}
{"doc": { "name": "John Doe becomes Jane Doe" } }
{"delete":{"_id":"2"}}
# 使用SQL查询
POST /_sql?format=txt
{
"query": "SELECT eleId,eleCode,eleType,eleName,eleContent FROM element LIMIT 10"
}
# 分词引擎分析
POST _analyze
{
"analyzer": "ik_smart",
"text": "pafcmall电商项目"
}
# match查询
GET /test/_search
{
"query" : {
"match" : { "name" : "word" }
}
}
# term查询
GET /test/_search
{
"query" : {
"term" : { "name" : "word" }
}
}
💂 个人主页: 白纸君
🤟 版权: 本文由白纸君原创、在优快云首发、需要转载请联系博主
💬 如果文章对你有帮助、欢迎关注、点赞、收藏(一键三连)和订阅专栏哦。
💅 有任何问题欢迎私信,看到会及时回复!