Query DSL
1. 分页
from, size。from从0开始
搜索第二页
POST /get-together/_search
{
"query": {
"match_all": {}
},
"from": 3,
"size": 3
}
size的大小不能超过index.max_result_window这个参数设置,默认值10000。
2. 返回字段_source
通过在搜索中指定_source来控制返回哪些字段。没有指定默认返回所有字段,如果_source没有存储,那么就只返回匹配文档的元数据信息_id,_type等
POST /get-together/_search
{
"query": {
"match_all": {}
},
"_source": ["name","location_group"]
}
# 还可以指定通配符,不仅可以指定哪些字段需要返回,还可以指定哪些字段不需要返回
POST /get-together/_search
{
"query": {
"match_all": {}
},
"_source": {
"includes": ["location.*", "date", "name"],
"excludes": "location_group"
}
}