elastic(6) mget
转自:https://www.cnblogs.com/zhaijunming5/p/6424800.html
GET /library/books/1

{
"_index": "library",
"_type": "books",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"title": "Elasticsearch:the definitive guide",
"name": {
"first": "zachary",
"last": "tong"
},
"publish_date": "2017-02-19",
"price": "49.99"
}
}

GET /library/books/2

{
"_index": "library",
"_type": "books",
"_id": "2",
"_version": 1,
"found": true,
"_source": {
"title": "Elasticsearch:the definitive guide",
"name": {
"first": "zachary",
"last": "tong"
},
"publish_date": "2017-02-19",
"price": "59.99"
}
}

multi get
多字段查询可以设置多个文档查询条件,每个查询条件在结构上都比较类似

GET /_mget
{ "docs": [
{
"_index" : "library",
"_type" : "books",
"_id" : "1"
},
{
"_index" : "library",
"_type" : "books",
"_id" : "2"
}
] }

当然,在查询条件中,body中_index字段也可以放在查询字符串中

GET /library/_mget
{ "docs": [
{ "_type" : "books",
"_id" : "1"
},
{ "_type" : "books",
"_id" : "2"
}
] }

对于type也是一样:

GET /library/books/_mget
{ "docs": [
{
"_id" : "1"
},
{
"_id" : "2"
}
]
}

如果索引和类型都放在查询URL中,那么字段ID就可以放在一个数组中:
GET /library/books/_mget
{
"ids" : ["1","2"]
}
如果想要查询不通类型的相同ID,就需要指定类型名称

GET /test/_mget/
{
"docs" : [
{
"_type":"typeA",
"_id" : "1"
},
{
"_type":"typeB",
"_id" : "1"
}
]
}
#这个例子不适用上面的测试数据

Fields过滤
fields过滤是获取指定的字段
代码

GET /_mget
{
"docs" : [
{
"_index":"library",
"_type" : "books",
"_id" : "1",
"fields" : ["publish_date","price"]
},
{
"_index":"library",
"_type" : "books",
"_id" : "2",
"fields" : ["publish_date","price"]
}
] }

结果

{
"docs": [
{
"_index": "library",
"_type": "books",
"_id": "1",
"_version": 1,
"found": true,
"fields": {
"publish_date": [
"2017-02-19"
],
"price": [
"49.99"
]
}
},
{
"_index": "library",
"_type": "books",
"_id": "2",
"_version": 1,
"found": true,
"fields": {
"publish_date": [
"2017-02-19"
],
"price": [
"59.99"
]
}
}
]
}
elastic(6) mget的更多相关文章
- Elastic Search快速上手(2):将数据存入ES
前言 在上手使用前,需要先了解一些基本的概念. 推荐 可以到 https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.htm ...
- elastic search使用总结
1. elasticsearch安装 官方下载地址:https://www.elastic.co/downloads/elasticsearch 解压文件 elasticsearch-2.4.0.zi ...
- Assign an Elastic IP Address to Your Instance
By default, an instance in a nondefault VPC is not assigned a public IP address, and is private.You ...
- 浅谈FTP 与 LFTP 的 nlist 和 mget 功能
最近因为业务需要,与第三方数据厂商做数据对接,接口方式协定为 FTP传输 ,说说我过程中的dan teng 经历. 开始准备用 lftp mirror 的方式镜像的方式同步数据,由于对方提供的日志文件 ...
- How to ssh to your Amazon Elastic Beanstalk instance?
Well, if it's ec2 or a digital ocean server, it would be a lot easier- you do what you normally do f ...
- 跨平台开源通讯组件elastic communication
elastic communication是基于c#开发支持.net和mono的通讯组件(简称EC),EC的主要目的简化mono和.net下的通讯开发难度,通过EC可以非常快速地开发基于mono和.n ...
- Elasticsearch增删改查 之 —— mget多文档查询
之前说过了针对单一文档的增删改查,基本也算是达到了一个基本数据库的功能.本篇主要描述的是多文档的查询,通过这个查询语法,可以根据多个文档的查询条件,返回多个文档集合. 更多内容可以参考我整理的ELK文 ...
- Elastic Image Slider 带缩略图功能的幻灯片
今天我们要为您展示如何创建一个简单的弹性幻灯片,带有缩略图预览功能.Elastic Image Slider 这款幻灯片能够自动调整以适应到其父容器,我们可以通过幻灯片使用缩略图预览或幻灯片的自动播放 ...
- elastic search 配置问题
http://www.elastic.co/guide/en/elasticsearch/guide/current/hardware.html 此处有关于ES硬件规格的建议和各种推荐参数. 内存: ...
随机推荐
- 使用 Spring Boot 快速构建 Spring 框架应用
Spring 框架对于很多 Java 开发人员来说都不陌生.自从 2002 年发布以来,Spring 框架已经成为企业应用开发领域非常流行的基础框架.有大量的企业应用基于 Spring 框架来开发.S ...
- Python快速学习-高级特性
1.切片 取一个list或tuple的部分元素是非常常见的操作 L = ['hello','the','world','and','my','love'] 取前三个元素 L[0:3],L[:3] 取倒 ...
- linux学习-磁盘管理
- SpringBoot- springboot集成Redis出现报错:No qualifying bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory'
Springboot将accessToke写入Redisk 缓存,springboot集成Redis出现报错 No qualifying bean of type 'org.springframewo ...
- 使用Blob获取图片并二进制显示实例页面
HTML代码: <div id="forAppend" class="demo"></div> JS代码: var eleAppend ...
- SQL Server 2016 —— 聚集列存储索引的功能增强
作者 Jonathan Allen,译者 邵思华 发布于 2015年6月14日 聚集列存储索引(CC Index)是SQL Server 2014中两大最引 ...
- 命令——WPF学习之深入浅出
WPF学习之深入浅出话命令 WPF为我们准备了完善的命令系统,你可能会问:“有了路由事件为什么还需要命令系统呢?”.事件的作用是发布.传播一些消息,消息传达到了接收者,事件的指令也就算完成了,至于 ...
- SpringTask定时任务实例讲解【Java获取微信公众平台accessToken及jsapiTicket】
项目中调用微信公众平台的接口时,因为获取到的accessToken及jsapiTicket有效时长只有两个小时,需要不断更新. 所以做了个定时任务,记录一下. .SpringTask实现有两种方式,一 ...
- html5 video 监听播放结束. 最好获取html标签而不是id。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- BEC translation exercise 7
在挑选时我们完全出自疏忽而漏过了这篇短文.In making the selection we passed this short piece by quite inadvertently. we l ...