开发者学堂课程【ElasticSearch 入门精讲:match_all】学习笔记,与课程紧密连接,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/631/detail/10020
match_all
ES Rest_match_all
curl-XPOST ‘localhost9200/bank/_search?pretty'-d
Pretty (返回的结果)-d(如果通过 head 插入,可省略,直接写参数体)
‘{
"query”: {“match_all”: {}},
"size”:1
}’
如果不指定 size,默认是返回10条文档信息
"size”:1(默认是返回1条文档信息)
查询
http://janson01:9200/bank/
search?preety POST
{
"query”: {
“match_all”: {}
},
“size”: “1”
}
(也可用“size”:1)
提交请求后
{
“took": 42,
“timed_out": false,
“_shards": {
"total”: 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
“hits”: {
"total": 1000,
"max_score":1,
"hits": [
{
“_index": "bank",
"_type": "account",
match_all &返回11到20个文档信息(分页)
curl-XPOST ‘localhost:9200/bank/search?pretty’ -d
‘{
"query”: (“match_all”: {}),
"from”: 10
"size: 10
}’
from :指定文档索引从哪里开始,默认从0开始
size:从 from 开始,返回多个文档
这基本上就为分页奠定了基础
match_all & 根据 account 的 balance 降序排序&返回10个文档(默认10个)
curl-XPOST ‘localhost9200/bank/search?pretty’ -d
‘{
"query": {“match_all”: {}},
“sort”: {“balance”:{“order” :”desc"}}
]’
查询
http://janson01:9200/bank/
_
search?preety POST
{
"query”: {
“match_all”: {}
},
“from”:11,
“size”: 10
}
查询 http://janson01:9200/bank/
_
search?preety POST
{
"query”: {
“match_all”: {}
},
“sort”: {
“balance”: {
“order”; “desc”
}
}
}
提交请求后按 balance 降序排列