GET _search
{
"query": {
"match_all": {}
}
}
GET _cat/indices
GET /dy_operation_log/_search
#插入一条记录
PUT /employee/_doc/1
{
"name":"name1",
"age":12
}
#查询index
GET /employee/_search
#查询指定记录
GET /employee/_doc/1
#修改指定字段
POST /employee/_update/1
{
"name":"name1-1"
}
POST /employee/_doc/1
{
"age":33
}
#新加字段信息
POST /employee/_doc/1
{
"name":"兄弟",
"age":33
}
#强制指定创建,如果存在,则失败
POST /employee/_create/2
{
"name":"xxx",
"age":12
}
POST /employee/_create/3
{
"name":"兄长",
"age":34
}
POST /employee/_create/4
{
"name":"兄长2",
"age":35
}
GET /employee/_doc/3
#修改指定字段
POST /employee/_update/3
{
"doc": {
"name":"大兄长"
}
}
#删除某文档
DELETE /employee/_doc/2
#删除索引
DELETE /employee
#创建结构化的模板
PUT /employee
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 2
},
"mappings": {
"properties": {
"name":{"type": "text"},
"age":{"type":"integer"}
}
}
}
#不带条件查询所有记录
GET /employee/_search
{
"query": {
"match_all": {}
}
}
#分页查询
GET /employee/_search
{
"query": {
"match_all": {}
},
"from": 0,
"size": 1
}
#带条件查询
GET /employee/_search
{
"query": {
"match": {
"name": "兄"
}
},
"sort":[
{"age" :{"order": "desc"}}
]
}
#filter 是进行过滤,将不再使用score进行打分
#带filter的查询,team: 与sql中的 where =相同
GET /employee/_search
{
"query": {
"bool": {
"filter":[
{"term":{"age": "33"}}
]
}
}
}
#带filter的查询,match: 与sql中的where like 类似,但增加分词器的匹配查询
GET /employee/_search
{
"query": {
"bool": {
"filter":[
{"match":{"name": "兄xxx"}}
]
}
}
}
#带聚合查询
GET /employee/_search
{
"query": {
"match": {
"name": "兄"
}
},
"sort":[
{"age" :{"order": "desc"}}
],
"aggs": {
"group_by_age": {
"terms": {
"field": "age",
"size": 10
}
}
}
}