转自: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. 在java中public void与public static void区别

    static 方法可以被main方法直接调用,而非static方法不可以.因为static方法是属于类的,是类方法.可以通过类名.方法名直接调用.而非static方法必须等对象被new出来以后才能使用 ...

  2. BZOJ 2425 [HAOI2010]计数:数位dp + 组合数

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2425 题意: 给你一个数字n,长度不超过50. 你可以将这个数字: (1)去掉若干个0 ( ...

  3. 使用struts碰到的错误

    这种错误更有可能url中路径写错了. 而这种情况更有可能使struts.xml写错了.特别要注意action的属性值class的编写是否正确.

  4. OA系统是什么,为什么要用OA系统呢?

    OA系统即是办公自动化(OA),是面向组织的日常运作和管理,员工及管理者使用频率最高的应用系统,自1985年国 内召开第一次办公自动化规划会议以来,OA系统在应用内容的深度与广度.IT技术运用等方面都 ...

  5. Jenkins自动化部署及代码检查配置应用

    首先jenkins是基于java开发的一种持续集成工具,它的存在和实际应用使得我们在开发过程中节省了很多宝贵时间,既然基于java,所以java环境是必须的. 其次Tomcat是针对Java的一个开源 ...

  6. 1001 字符串“水”题(二进制,map,哈希)

    1001: 字符串“水”题 时间限制: 1 Sec  内存限制: 128 MB提交: 210  解决: 39[提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串(1<=n<= ...

  7. The RK3066/RK30SDK Android 4.2 audio codec has a bug!

    在文件kernel/sound/soc/soc-core.c中,函数soc_bind_dai_link引入了一个新定义的宏CODEC_NAME_CMP,这个新玩意导致了后面的strcpy(p_code ...

  8. mac上获取手机的uuid

    把手机连上mac 终端中输入: system_profiler SPUSBDataType | grep "Serial Number:.*" 修改用 | sed s#" ...

  9. LeetCode OJ:Largest Number(最大数字)

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  10. LeetCode OJ:Delete Node in a Linked List(链表节点删除)

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...