我有一个Elasticsearch搜索查询,它以分页的方式获取文档,如下所示:
{
"from" : 5, "size" : 2,
"sort" : [
{ "title" : {"order" : "asc"}}
],
"query" : {
"match_all": {}
},
"_source": ["title"]
}
我想获得from
和size
从ES当前未从上面的查询返回的响应返回。任何指针都将非常有帮助。
ES当前不返回已在请求中发送的分页参数。您需要破解...或提交功能请求
您可以使用命名查询来在几乎所有查询中传递该信息,但是,您需要等到ES 5match_all
支持命名查询:
{
"from" : 5, "size" : 2,
"sort" : [
{ "title" : {"order" : "asc"}}
],
"query" : {
"match_all": {"_name": "5:2"} <--- name the query with the from/size params
},
"_source": ["title"]
}
在响应中,您将获得"5:2"
可以解析的内容,以弄清过去from
和size
过去。
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "test",
"_type": "test",
"_id": "1",
"_score": 1,
"_source": {
"test": "test"
},
"matched_queries": [ <--- you can find from/size here
"5:2"
]
}
]
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句