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性能问题的更多相关文章

  1. ElasticSearch(十四) _search api search timeout 机制

    语法:timeout=10ms,timeout=1s,timeout=1m GET /_search?timeout=10m timeout:默认无timeout,latency平衡completen ...

  2. Python 学习 第十五篇:模块搜索路径和包导入

    在导入自定义的模块时,除了指定模块名之外,也需要指定目录,由于Python把目录称作包,因此,这类导入被称为包导入.包导入把计算机上的目录变成Python的命名空间,而目录中所包含的子目录和模块文件则 ...

  3. 十五、API请求接口-远程服务器返回错误: (400) 错误的请求错误

    一.远程服务器返回错误: (400) 错误的请求错误 捕获异常查看具体错误 using Newtonsoft.Json; using System; using System.Collections. ...

  4. 【.NET Core项目实战-统一认证平台】第十五章 网关篇-使用二级缓存提升性能

    [.NET Core项目实战-统一认证平台]开篇及目录索引 一.背景 首先说声抱歉,可能是因为假期综合症(其实就是因为懒哈)的原因,已经很长时间没更新博客了,现在也调整的差不多了,准备还是以每周1-2 ...

  5. 论文阅读笔记二十五:Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition(SPPNet CVPR2014)

    论文源址:https://arxiv.org/abs/1406.4729 tensorflow相关代码:https://github.com/peace195/sppnet 摘要 深度卷积网络需要输入 ...

  6. Elasticsearch由浅入深(七)搜索引擎:_search含义、_multi-index搜索模式、分页搜索以及深分页性能问题、query string search语法以及_all metadata原理

    _search含义 _search查询返回结果数据含义分析 GET _search { , "timed_out": false, "_shards": { , ...

  7. Elasticsearch系列---搜索分页和deep paging问题

    概要 本篇从介绍搜索分页为起点,简单阐述分页式数据搜索与原有集中式数据搜索思维方式的差异,就分页问题对deep paging问题的现象进行分析,最后介绍分页式系统top N的案例. 搜索分页语法 El ...

  8. ES 25 - Elasticsearch的分页查询及其深分页问题 (deep paging)

    目录 1 分页查询方法 2 分页查询的deep paging问题 1 分页查询方法 在GET请求中拼接from和size参数 // 查询10条数据, 默认从第0条数据开始 GET book_shop/ ...

  9. 36.分页及deep paging

    主要知识点 1.es分页 2.deep paging     一.es分页语法 size,from 这两个关键字 GET /_search?size=10 指定每页10条数据 GET /_search ...

随机推荐

  1. linux内核之进程的基本概念(进程,进程组,会话关系)

    进程是操作系统的一个核心概念.每个进程都有自己唯一的标识:进程ID,也有自己的生命周期.一个典型的进程的生命周期如图4-1所示. 进程都有父进程,父进程也有父进程,这就形成了一个以init进程为根的家 ...

  2. Scrapy学习-11-Selector对象使用

    Selector使用 使用背景 我需要使用类似spider项目中,response使用的xpath和css获取页面指定数据,但因为爬取页面较小我们不想创建一个spider项目时,就可以使用scrapy ...

  3. Day 19 函数之闭包、装饰器

    一.什么是装饰器 器即函数 装饰即修饰,意指为其他函数添加新功能 装饰器定义:本质就是函数,功能是为其他函数添加新功能 二.装饰器遵循的原则 1.不修改被装饰函数的源代码(开放封闭原则) 2.为被装饰 ...

  4. python常用模块2

    collections模块 在内置数据类型(dict.list.set.tuple)的基础上,collections模块还提供了几个额外的数据类型:Counter.deque.defaultdict. ...

  5. Codeforces 946 B.Weird Subtraction Process

    B. Weird Subtraction Process   time limit per test 1 second memory limit per test 256 megabytes inpu ...

  6. [原创][FPGA]Quartus实用小技巧(长期更新)

    0. 简介 在使用Quartus软件时,经常会时不时的发现一些小技巧,本文的目的是总结所查阅或者发现到的小技巧,本文长期更新. 1. Quartus中的模板功能 最近在Quartus II的菜单里找到 ...

  7. 洛谷——P1331 海战

    P1331 海战 题目描述 在峰会期间,武装部队得处于高度戒备.警察将监视每一条大街,军队将保卫建筑物,领空将布满了F-2003飞机.此外,巡洋船只和舰队将被派去保护海岸线.不幸的是因为种种原因,国防 ...

  8. awk数组详解、实战

    1.其它编程语言数组的下标一般从0开始,awk中数组下标默认从1开始,也可以从0开始设置: awk 'BEGIN{huluwa[0]="大娃";huluwa[1]="二娃 ...

  9. [HEOI2015]定价

    题目描述 在市场上有很多商品的定价类似于 999 元.4999 元.8999 元这样.它们和 1000 元.5000 元和 9000 元并没有什么本质区别,但是在心理学上会让人感觉便宜很多,因此也是商 ...

  10. Mybatis逆向生成使用扩展类

    1.背景介绍 用的mybatis自动生成的插件,然而每次更改数据库的时候重新生成需要替换原有的mapper.xml文件,都要把之前业务相关的sql重新写一遍,感觉十分麻烦,就想着把自动生成的作为一个基 ...