es 查询
条件查询
放在请求地址上
http://127.0.0.1:9200/shopping/_search?q=name:qingmu123

放在请求体中进行查询
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match":{
"name":"qingmu123"
}
}
}

全量查询
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match_all":{
}
}
}
分页查询
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match_all":{
}
},
"from":0,
"size":2
}
指定展示某个字段
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match_all":{
}
},
"from":0,
"size":2,
"_source":["name"]
}
排序
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match_all":{
}
},
"from":0,
"size":2,
"_source":["name"],
"sort":{
"age":{
"order":"desc"
}
}
}
多条件查询
and
http://127.0.0.1:9200/shopping/_search
{
"query":{
"bool":{
"must":[{
"match":{
"name":"小米"
}
},
{
"match":{
"age":18
}
}]
}
}
}
or
http://127.0.0.1:9200/shopping/_search
{
"query":{
"bool":{
"should":[{
"match":{
"name":"小米"
}
},
{
"match":{
"age":18
}
}]
}
}
}
filter
http://127.0.0.1:9200/shopping/_search
{
"query":{
"bool":{
"must":[{
"match":{
"name":"小米"
}
},
{
"match":{
"age":18
}
}
],
"filter":{
"rang":{
"age":{
}
}
}
}
}
}
全文检索
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match":{
"name":"米"
}
}
}

完全匹配
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match_phrase":{
"name":"米"
}
}
}
高亮
GET请求
http://127.0.0.1:9200/shopping/_search
{
"query":{
"match_phrase":{
"name":"米"
}
},
"highlight":{
"fields":{
"name":{}
}
}
}
聚合操作
本文来自博客园,作者:King-DA,转载请注明原文链接:https://www.cnblogs.com/qingmuchuanqi48/articles/15891231.html

浙公网安备 33010602011771号