转自: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的更多相关文章

  1. Elastic Search快速上手(2):将数据存入ES

    前言 在上手使用前,需要先了解一些基本的概念. 推荐 可以到 https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.htm ...

  2. elastic search使用总结

    1. elasticsearch安装 官方下载地址:https://www.elastic.co/downloads/elasticsearch 解压文件 elasticsearch-2.4.0.zi ...

  3. 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 ...

  4. 浅谈FTP 与 LFTP 的 nlist 和 mget 功能

    最近因为业务需要,与第三方数据厂商做数据对接,接口方式协定为 FTP传输 ,说说我过程中的dan teng 经历. 开始准备用 lftp mirror 的方式镜像的方式同步数据,由于对方提供的日志文件 ...

  5. 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 ...

  6. 跨平台开源通讯组件elastic communication

    elastic communication是基于c#开发支持.net和mono的通讯组件(简称EC),EC的主要目的简化mono和.net下的通讯开发难度,通过EC可以非常快速地开发基于mono和.n ...

  7. Elasticsearch增删改查 之 —— mget多文档查询

    之前说过了针对单一文档的增删改查,基本也算是达到了一个基本数据库的功能.本篇主要描述的是多文档的查询,通过这个查询语法,可以根据多个文档的查询条件,返回多个文档集合. 更多内容可以参考我整理的ELK文 ...

  8. Elastic Image Slider 带缩略图功能的幻灯片

    今天我们要为您展示如何创建一个简单的弹性幻灯片,带有缩略图预览功能.Elastic Image Slider 这款幻灯片能够自动调整以适应到其父容器,我们可以通过幻灯片使用缩略图预览或幻灯片的自动播放 ...

  9. elastic search 配置问题

    http://www.elastic.co/guide/en/elasticsearch/guide/current/hardware.html 此处有关于ES硬件规格的建议和各种推荐参数. 内存: ...

随机推荐

  1. C# 反射通过GetCustomAttributes方法,获得自定义特性

    http://blog.csdn.net/litao2/article/details/17633107 使用反射访问: 自定义属性的信息和对其进行操作的方法. 一.实例1 1.代码: 如:Syste ...

  2. 在虚拟机里安装ubuntu

    1.下载ubuntu镜像文件 https://mirrors.aliyun.com/ubuntu-releases/17.04/ubuntu-17.04-desktop-amd64.iso 2.创建虚 ...

  3. 维度属性的KeyColumns,NameColumn和ValueColumn

      维度的每一个属性都有KeyColumns,NameColumn和ValueColumn 1,如何理解KeyColumns,NameColumn和ValueColumn?对一行记录有不同的标识列,但 ...

  4. jsp:jstl标签库国际化 fmt

    首先资源文件目录是:src/man/sources (这是它默认的资源文件) i18n_en_US.properties文件内容 copyright=Copyright \u00A9 2013 lan ...

  5. 微软面向高并发应用而推出的新程序库——TPL Dataflow

    TPL Dataflow库的几个扩展函数 TPL Dataflow是微软面向高并发应用而推出的新程序库.借助于异步消息传递与管道,它可以提供比线程池更好的控制.本身TPL库在DataflowBlock ...

  6. QT Creator引用win32 api类库方法(.lib)

    由于Qt Creator使用的是mingW进行程序编译,该编译方式无法识别#pragma comment(lib,"lib\\hvdailt.lib")引用. 所以需要在.Pro文 ...

  7. ES6环境配置

    1.电脑有node环境,运行npm init 2.cnpm i -D babel-core babel-preset-es2015 babel-preset-latest 3.创建.babelrc文件 ...

  8. List集合添加自定义对象

    public class Student { private String name; private int age; public Student() { super(); } public St ...

  9. git教程3-添加远程库与从远程库拷贝

    一.添加到github 1.github上创建新的库learngit.git 2.git remote add origin git@github.com:moisiet/learngit.git  ...

  10. Android源代码因删除所有git仓库导致的编译错误

    /******************************************************************************** * Android源代码因删除所有g ...