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 ...
随机推荐
- WEB学习-CSS行高、字体,链接的美化以及背景
行高和字号 CSS中,所有的行,都有行高.盒模型的padding,绝对不是直接作用在文字上的,而是作用在“行”上的. 单行文本垂直居中 文本在行里面是居中 其中,行高:盒子高; 需要注意的是,这个小技 ...
- 支持C++11标准
设置CB下的GCC. Settings->Compiler->Compiler Settings勾选Have g++ follow the C++11 ISO C++ language s ...
- [java基础] 001 - 记一次堆栈溢出异常(StackOverFlowError)
上午经理发来一个任务,解决某个接口异常,此接口第一次调用成功返回: {ret=Y, orderResultList=[{itemno=31920190521083622032, sub_msg=成功, ...
- 3.eclipse中 maven打包web工程几种方式
1.右键项目-export 选择war file导出即可 2.第二种:右键项目-RUN AS -maven build..goals填入:clean package 第三种方式:右键项目.选择Debu ...
- Java中判断String对象是否为空的方法
Java原生的方法: String对象中有一个isEmpty的方法判断是否为空,其实isEmpty完全等同于string.length()==0,注意如果String本身是null,那么使用strin ...
- Chrom查看Flash缓存文件及Flash下载方法
比如在优酷看视频时,或者熊猫直播,如果使用Flash进行播放的基本都会先缓存在本地,只不过这个缓存的名字后缀不叫flv,而是类似tmp这样:通常只要找到这个缓存文件,然后改为flv即可播放:如果出现文 ...
- iOS开发 绘图详解
Quartz概述 Quartz是Mac OS X的Darwin核心之上的绘图层,有时候也认为是CoreGraphics.共有两种部分组成 Quartz Compositor,合成视窗系统,管理和合 ...
- JAVA微信开发:[17]如何获取所有关注用户
该方法获取所有关注公共账号的微信用户的openId集合, 再通过openId集合既可以获取所有的用户的信息. /** * 获取所有的关注用户 * * @return */ public List ...
- BumpMapping [转]
http://fabiensanglard.net/bumpMapping/index.php Fabien Sanglard's Website Home About FAQ Email Rss T ...
- drag-html
<!doctype html><html><head><meta charset="UTF-8" /><title>Ca ...