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硬件规格的建议和各种推荐参数. 内存: ...
随机推荐
- java/jsp: 登录系统
db类 package db; import java.sql.*; import javax.naming.InitialContext; import javax.sql.DataSource ...
- openGL 3.3+ 场景渲染
这个渲染程序是研一下学期的计算机图形学课程大作业,花了两三周学习使用了下 openGL 3.3+ 库,整合出了这个渲染程序,完成于 2013/07/05. 相对于老版本的库,新版本更开放,给了程序员更 ...
- The import javax.servlet.jsp.JspWriter cannot be resolved' error
Add servlet-api.jar and jsp-api.jar from Tomcat 6.0 library to ecipse project.
- Swift 3.0 on Ubuntu 15.10
一.安装swift 3.0 1. 下载 https://swift.org/download/ 找到swift-3.0 ubuntu 15.10版本下载: https://swift.org/buil ...
- [1]移动端页面调试之“weinre大法”
前言 这个也是从早读课转载的.如有侵权请联系我马上下架. 正文从这开始-- 移动端页面调试一般分两步.第一步我们需要把本地(pc端)写的页面效果展现在移动端,一个很方便的办法是用 fiddler 作为 ...
- mysql ORM框架及SQLAlchemy
一 介绍 SQLAlchemy是Python编程语言下的一款ORM框架,该框架建立在数据库API之上,使用关系对象映射进行数据库操作,简言之便是:将对象转换成SQL,然后使用数据API执行SQL并获取 ...
- 面试题13:在O(1)时间删除链表结点
题目:给定单向链表的头指针和一个结点指针,定义一个函数在O(1)时间删除该结点. 链表结点与函数的定义如下: struct ListNode { int val; ListNode* next; }; ...
- 剑指offer--13.二进制中1的个数
就是猜测试数据没有负数,哈哈 ----------------------------------------------------------------- 时间限制:1秒 空间限制:32768K ...
- Dev c++在新建文件中插入文件头
在菜单栏中依次点击Tools->Editor Options->Snippets->Default Source 勾选Insert the following code into e ...
- 树莓派(Linux)与镜像源
树莓派学习笔记--修改树莓派软件源 1. linux 镜像源文件 >> vim /etc/apt/sources.list 可在树莓派官网 http://www.raspbian.org/ ...