ElasticSearch(十五) _search api 分页搜索及deep paging性能问题
1、分页搜索
语法:
size,from GET /_search?size=10
GET /_search?size=10&from=0
GET /_search?size=10&from=20
GET /index/type/_search
{
"query": { "match_all": {} },
"from": 1,
"size": 1
}
实际操作:
查看共有5条数据:
GET /test_index/test_type/_search
"hits" : {
"total" : 7,
"max_score" : 1.0,
我们假设将这7条数据分成3页,每一页是3条数据,来实验一下这个分页搜索的效果
第一页:
GET /test_index/test_type/_search?from=0&size=3 {
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 7,
"max_score" : 1.0,
"hits" : [
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "10",
"_score" : 1.0,
"_source" : {
"test_field1" : "test1",
"test_field2" : "test2"
}
},
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "12",
"_score" : 1.0,
"_source" : {
"num" : 1,
"tags" : [ ]
}
},
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "6",
"_score" : 1.0,
"_source" : {
"test_field" : "test test"
}
}
]
}
}
第二页:
GET /test_index/test_type/_search?from=3&size=3 {
"took" : 7,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 7,
"max_score" : 1.0,
"hits" : [
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"test_field" : "replaced test2"
}
},
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "Baq9WWgBjIP9BXE3vrJ2",
"_score" : 1.0,
"_source" : {
"test_field" : "auto-generate id test"
}
},
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"test_field1" : "test1",
"test_field2" : "bulk test1"
}
}
]
}
}
第三页:
GET /test_index/test_type/_search?from=6&size=3 {
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 7,
"max_score" : 1.0,
"hits" : [
{
"_index" : "test_index",
"_type" : "test_type",
"_id" : "11",
"_score" : 1.0,
"_source" : {
"num" : 0,
"tags" : [ ]
}
}
]
}
}
2、深度搜索deep paging的性能问题
ElasticSearch(十五) _search api 分页搜索及deep paging性能问题的更多相关文章
- ElasticSearch(十四) _search api search timeout 机制
语法:timeout=10ms,timeout=1s,timeout=1m GET /_search?timeout=10m timeout:默认无timeout,latency平衡completen ...
- Python 学习 第十五篇:模块搜索路径和包导入
在导入自定义的模块时,除了指定模块名之外,也需要指定目录,由于Python把目录称作包,因此,这类导入被称为包导入.包导入把计算机上的目录变成Python的命名空间,而目录中所包含的子目录和模块文件则 ...
- 十五、API请求接口-远程服务器返回错误: (400) 错误的请求错误
一.远程服务器返回错误: (400) 错误的请求错误 捕获异常查看具体错误 using Newtonsoft.Json; using System; using System.Collections. ...
- 【.NET Core项目实战-统一认证平台】第十五章 网关篇-使用二级缓存提升性能
[.NET Core项目实战-统一认证平台]开篇及目录索引 一.背景 首先说声抱歉,可能是因为假期综合症(其实就是因为懒哈)的原因,已经很长时间没更新博客了,现在也调整的差不多了,准备还是以每周1-2 ...
- 论文阅读笔记二十五:Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition(SPPNet CVPR2014)
论文源址:https://arxiv.org/abs/1406.4729 tensorflow相关代码:https://github.com/peace195/sppnet 摘要 深度卷积网络需要输入 ...
- Elasticsearch由浅入深(七)搜索引擎:_search含义、_multi-index搜索模式、分页搜索以及深分页性能问题、query string search语法以及_all metadata原理
_search含义 _search查询返回结果数据含义分析 GET _search { , "timed_out": false, "_shards": { , ...
- Elasticsearch系列---搜索分页和deep paging问题
概要 本篇从介绍搜索分页为起点,简单阐述分页式数据搜索与原有集中式数据搜索思维方式的差异,就分页问题对deep paging问题的现象进行分析,最后介绍分页式系统top N的案例. 搜索分页语法 El ...
- ES 25 - Elasticsearch的分页查询及其深分页问题 (deep paging)
目录 1 分页查询方法 2 分页查询的deep paging问题 1 分页查询方法 在GET请求中拼接from和size参数 // 查询10条数据, 默认从第0条数据开始 GET book_shop/ ...
- 36.分页及deep paging
主要知识点 1.es分页 2.deep paging 一.es分页语法 size,from 这两个关键字 GET /_search?size=10 指定每页10条数据 GET /_search ...
随机推荐
- yii 数据库添加,修改,删除相关操作总结
yii中关于数据信息的添加数据,修改数据,删除数据的相关操作,刚刚学习没几天,仅记录了一些,以后慢慢再充实,有需要的朋友可以看看. 添加数据的方法 (1)save 方法(对象形式操作) $user=n ...
- 洛谷—— P3807 【模板】卢卡斯定理
https://www.luogu.org/problemnew/show/3807 题目背景 这是一道模板题. 题目描述 给定n,m,p(1\le n,m,p\le 10^51≤n,m,p≤105) ...
- 洛谷——P2919 [USACO08NOV]守护农场Guarding the Farm
P2919 [USACO08NOV]守护农场Guarding the Farm 题目描述 The farm has many hills upon which Farmer John would li ...
- Socks5代理Socks5 Proxy
Socks5代理Socks5 Proxy Socks5代理是基于Socks协议的一种代理模式.其中,5表示该协议的版本号.它可以让局域网的计算机通过socks5代理服务器,访问外网的内容.由于它工 ...
- BZOJ3295动态逆序对
一道比较傻的CDQ分治 CDQ: 主要用于解决三位偏序的问题 #include<cstdio> #include<cctype> #include<algorithm&g ...
- 346. Moving Average from Data Stream
/* * 346. Moving Average from Data Stream * 2016-7-11 by Mingyang * 这里注意的就是(double) sum / count * su ...
- PHP微信公众平台OAuth2.0网页授权,获取用户信息代码类封装demo(二)
一.这个文件微信授权使用的是OAuth2.0授权的方式.主要有以下简略步骤: 第一步:判断有没有code,有code去第三步,没有code去第二步 第二步:用户同意授权,获取code 第三步:通过co ...
- Maven插件maven-antrun-plugin的使用
以下引用官方的介绍http://maven.apache.org/plugins/maven-antrun-plugin/: 一.什么是maven-antrun-plugin? 该插件提供从Maven ...
- Maven的构建生命周期理解
以下引用官方的生命周期解释https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html: 一.构建生命 ...
- asyncTask 的execute和executeOnExecutor 方法
asyncTask.execute Android.os.Build.VERSION_CODES.DONUT, this was changed to a pool of threads allowi ...