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硬件规格的建议和各种推荐参数. 内存: ...
随机推荐
- JMeter报错 ERROR o.a.j.t.JMeterThread: Test failed!
第一次用JMeter,然后跟着教程走,发现进行测试的时候直接报错 显示如下 反复测试依然报错,网上搜索也没什么结果,自己测试了一下才发现问题. 左边创建了CSV DATA 但是并没有进行设置 导致报 ...
- Android dependency has different version.You should manually set the same version via DependencyReso
有时候导入一些module时,会出现以下问题 Android dependency 'com.android.support:support-v4' has different version for ...
- alias 中使用awk
alias hehistory10='history |awk "{print \$2}"|sort|uniq -c|sort -rn|head -10' $要转义
- 解决:cmd中运行monkeyrunner monkey_recorder.py报错: Can't open specified script file
看lynnLi的博客monkeyrunner之录制与回放(七),遇到了一个问题,我在cmd中输入monkeyrunner monkey_recorder.py,却报错了: 当时第一个感觉时,先到\sd ...
- poj2135最小费用流
裸题,就是存个模板 最小费用流是用spfa求解的,目的是方便求解负环,spfa类似于最大流中的bfs过程 #include<map> #include<set> #includ ...
- SPOJ - BALNUM 数位dp
题意:求某一区间内的平衡数个数(指一个数,其中出现过的数,如果是偶数,那么必须出现奇数次,反之偶数次) 题解:用三进制来枚举(0到9)所有情况,0代表没有出现,1代表出现奇数次,2代表出现偶数次dp[ ...
- ural 2019 Pair: normal and paranormal
2019. Pair: normal and paranormal Time limit: 1.0 secondMemory limit: 64 MB If you find yourself in ...
- windows7安装Scrapy
在Linux下安装Scrapy很容易,基本不会出现问题 pip install Scrapy 但是在Windows下经常会出现问题,首先还是尝试一下使用pip命令: pip install scrap ...
- NAVICAT PREMIUM 初识
1 问题运行SQL取数语句出错?. 答案:因为运行SQL文件时没有这个表.新的数据库里面 解决方法: 获取需要建立的二维表创建语句 新建查询 输入语句,点击运行即可 解释注释语句: 主体为五个字段的主 ...
- vue-cli项目中如何使用锚点
两种方式: 1.使用vue-router实现锚点功能(利用html5的history模式,vue-router的滚动行为) import Vue from 'vue' import VueRouter ...