36.分页及deep paging
主要知识点
1、es分页
2、deep paging
一、es分页语法
size,from 这两个关键字
GET /_search?size=10 指定每页10条数据
GET /_search?size=10&from=0 指定每页10条数据,并从第0条数据开始
GET /_search?size=10&from=20 指定每页10条数据,并从第20条数据开始
注意size,from在前在后都没有关系。
二、es分页实例
1、先检查数据
GET /test_index/test_type/_search
结果是:
"hits": {
"total": 9,
"max_score": 1,
我们假设将这9条数据分成3页,每一页是3条数据,
GET /test_index/test_type/_search?from=0&size=3
结果是:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 9,
"max_score": 1,
"hits": [
{
"_index": "test_index",
"_type": "test_type",
"_id": "8",
"_score": 1,
"_source": {
"test_field": "test client 2"
}
},
{
"_index": "test_index",
"_type": "test_type",
"_id": "6",
"_score": 1,
"_source": {
"test_field": "tes test"
}
},
{
"_index": "test_index",
"_type": "test_type",
"_id": "4",
"_score": 1,
"_source": {
"test_field": "test4"
}
}
]
}
}
第一页:id=8,6,4
GET /test_index/test_type/_search?from=3&size=3
第二页:id=2,自动生成,7
GET /test_index/test_type/_search?from=6&size=3
第三页:id=1,11,3
可以看出,es分页是以_source排序,不是以id排序
三、deep paging
1、什么是deep paging
简单来说就是搜索的特别深,假如说现在es中有6000条数据,分别存在3个primary shard中,要在这6000条数据中搜索中第100页的数据(每页10条),这种情况就是deep paging,
2、deep paging的做法
最常想到的做法是,在每个shard中搜索1000到1010这10条数据,然后用这30条数据排序,排序之后取10条数据就是要搜索的数据,这种做法是错的,因为3个shard中的数据的_source分数不一样,可能这某一个shard中第一条数据的_source分数比另一个shard中第1000条都要高,所以在每个shard中搜索1000到1010这10条数据然后排序的做法是不正确的,鉴于这种情况,正确的做法是把这三个shard中的0到1010条数据全部搜索出来(按排序顺序),然后全部返回给coordinate node,由coordinate node按_source分数排序后,得到想要的结果。然后返回给客户端。
3、deep paging性能问题
(1)耗费网络带宽,因为搜索过深的话,各shard要把数据传送给coordinate node,这个过程是有大量数据传递的,消耗网络,
(2)消耗内存,各shard要把数据传送给coordinate node,这个传递回来的数据,是被coordinate node保存在内存中的,这样会大量消耗内存。
(3)消耗cpu coordinate node要把传回来的数据进行排序,这个排序过程很消耗cpu.
鉴于deep paging的性能问题,所以在实际工作中应尽量减少使用。
36.分页及deep paging的更多相关文章
- 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/ ...
- ElasticSearch(十五) _search api 分页搜索及deep paging性能问题
1.分页搜索 语法: size,from GET /_search?size=10 GET /_search?size=10&from=0 GET /_search?size=10&f ...
- 游标 深度分页 deep paging
Solr Deep Paging(solr 深分页) - ickes的专栏 - CSDN博客 https://blog.csdn.net/xl_ickes/article/details/427725 ...
- ElasticSearch7.3学习(十九)---- deep paging
1.什么是deep paging 根据相关度评分倒排序,所以分页过深,协调节点会将大量数据聚合分析. 2.deep paging 性能问题 1消耗网络带宽,因为所搜过深的话,各 shard 要把数据传 ...
- 深分页(Deep Pagination)
取回阶段 | Elasticsearch: 权威指南 | Elastic https://www.elastic.co/guide/cn/elasticsearch/guide/current/_fe ...
- Elasticsearch由浅入深(七)搜索引擎:_search含义、_multi-index搜索模式、分页搜索以及深分页性能问题、query string search语法以及_all metadata原理
_search含义 _search查询返回结果数据含义分析 GET _search { , "timed_out": false, "_shards": { , ...
- elasticserach数据库深度分页查询的原理
深度分页存在的问题 https://segmentfault.com/a/1190000019004316?utm_source=tag-newest 在实际应用中,分页是必不可少的,例如,前端页面展 ...
- 〈三〉ElasticSearch的认识:搜索、过滤、排序
目录 上节回顾 本节前言 文档的搜索 URL参数条件搜索 请求体条件搜索 语法与示例: 补充: 小节总结: 文档的过滤filter 语法与举例: filter与bool constant_score ...
随机推荐
- poj 3468 A Simple Problem with Integers(线段树+区间更新+区间求和)
题目链接:id=3468http://">http://poj.org/problem? id=3468 A Simple Problem with Integers Time Lim ...
- Java时间转换
package com.fh.util; import java.sql.Timestamp; import java.text.DateFormat; import java.text.ParseE ...
- ListView点击或选中item改变背景
点击或选中ListView中的一项后.使item背景改变,失去焦点相同显示选中的背景.又一次选中另外一项才刷新: 在Adapter中配置: public class MyAdapter extends ...
- job调度时间格式
*/5 * * * * ?---------------每隔5秒执行一次0 */1 * * * ?---------------每隔1分钟执行一次0 0 23 * * ?--------------- ...
- C# datagridview 删除行(转 学会、放弃博客)
原文引入:http://zhangyanyansy.blog.163.com/blog/static/13530509720106171252978/ datagridview 删除行 2010-07 ...
- C# textbox中输入时加限制条件 // C#Winform下限制TextBox只能输入数字 // 才疏学浅(TextBox 小数点不能在首位+只能输入数字)
textbox中输入时加限制条件 分类: C# winform2008-08-26 08:30 306人阅读 评论(0) 收藏 举报 textbox正则表达式object 1.用正则表达式! 2.使用 ...
- CodeForces 754D Fedor and coupons&&CodeForces 822C Hacker, pack your bags!
D. Fedor and coupons time limit per test 4 seconds memory limit per test 256 megabytes input standar ...
- Oracle_exp/expdp备份
目录索引 1.exp和expdp的区别 2.expdp导出数据库流程 一.↓↓exp和expdp的区别↓↓ 1.exp和expdp最明显的区别就是导出速度的不同.expdp导出是并行导出(如果把exp ...
- Django之ORM的增删改查操作流程
总结:ORM的 查.增.删.改 - 查 - client - 有一个展示页面(xxx_show.html) - 这一个页面一输入执行后,get请求向server端发送 - 这个展示页面有添加按钮.删除 ...
- 努比亚(nubia) M2青春版 NX573J 解锁BootLoader 并进入临时recovery ROOT
努比亚(nubia) M2青春版 NX573J 解锁BootLoader 并进入临时recovery ROOT 工具下载链接:https://pan.baidu.com/s/1NfRTdXtdAZRi ...