这是个查询命令。

前期博客

Elasticsearch之CURL命令的PUT和POST对比

  1、

  以上是根据员工id查询。

  即在任意的查询字符串中添加pretty参数,es可以得到易于我们识别的json结果。(这一点必须要会)

[hadoop@master elasticsearch-2.4.]$ curl -XGET http://master:9200/zhouls/user/1
{"_index":"zhouls","_type":"user","_id":"","_version":,"found":true,"_source":{"name" : "john" , "age" : }}[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$ curl -XGET http://master:9200/zhouls/user/1?pretty
{
"_index" : "zhouls",
"_type" : "user",
"_id" : "",
"_version" : ,
"found" : true,
"_source" : {
"name" : "john",
"age" :
}
}
[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$

  2、由此,可见,检索文档中的一部分,可以只查询,只需要显式部分字段。

[hadoop@master elasticsearch-2.4.]$ curl -XGET 'http://master:9200/zhouls/user/1?_source=name,age&pretty'
{
"_index" : "zhouls",
"_type" : "user",
"_id" : "",
"_version" : ,
"found" : true,
"_source" : {
"age" : ,
"name" : "john"
}
}
[hadoop@master elasticsearch-2.4.]$ curl -XGET 'http://master:9200/zhouls/user/1?_source=name&pretty'
{
"_index" : "zhouls",
"_type" : "user",
"_id" : "",
"_version" : ,
"found" : true,
"_source" : {
"name" : "john"
}
}
[hadoop@master elasticsearch-2.4.]$

  3、查询指定索引库的指定类型的所有数据

[hadoop@master elasticsearch-2.4.]$ curl -XGET 'http://master:9200/zhouls/user/_search'
{"took":,"timed_out":false,"_shards":{"total":,"successful":,"failed":},"hits":{"total":,"max_score":1.0,"hits":[{"_index":"zhouls","_type":"user","_id":"","_score":1.0,"_source":{"name" : "john" , "age" : }},{"_index":"zhouls","_type":"user","_id":"","_score":1.0,"_source":{"name" : "john" , "age" : }},{"_index":"zhouls","_type":"user","_id":"AVz5Q9u7U8bDb6QDgbDS","_score":1.0,"_source":{"name" : "john"}},{"_index":"zhouls","_type":"user","_id":"","_score":1.0,"_source":{"name" : "john" , "age" : }}]}}[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$ curl -XGET 'http://master:9200/zhouls/user/_search?pretty'
{
"took" : ,
"timed_out" : false,
"_shards" : {
"total" : ,
"successful" : ,
"failed" :
},
"hits" : {
"total" : ,
"max_score" : 1.0,
"hits" : [ {
"_index" : "zhouls",
"_type" : "user",
"_id" : "",
"_score" : 1.0,
"_source" : {
"name" : "john",
"age" :
}
}, {
"_index" : "zhouls",
"_type" : "user",
"_id" : "",
"_score" : 1.0,
"_source" : {
"name" : "john",
"age" :
}
}, {
"_index" : "zhouls",
"_type" : "user",
"_id" : "AVz5Q9u7U8bDb6QDgbDS",
"_score" : 1.0,
"_source" : {
"name" : "john"
}
}, {
"_index" : "zhouls",
"_type" : "user",
"_id" : "",
"_score" : 1.0,
"_source" : {
"name" : "john",
"age" :
}
} ]
}
}
[hadoop@master elasticsearch-2.4.]$

  4、根据条件进行查询

[hadoop@master elasticsearch-2.4.]$ curl -XGET 'http://master:9200/zhouls/user/_search?q=name:john'
{"took":,"timed_out":false,"_shards":{"total":,"successful":,"failed":},"hits":{"total":,"max_score":1.0,"hits":[{"_index":"zhouls","_type":"user","_id":"","_score":1.0,"_source":{"name" : "john" , "age" : }},{"_index":"zhouls","_type":"user","_id":"AVz5Q9u7U8bDb6QDgbDS","_score":1.0,"_source":{"name" : "john"}},{"_index":"zhouls","_type":"user","_id":"","_score":0.30685282,"_source":{"name" : "john" , "age" : }},{"_index":"zhouls","_type":"user","_id":"","_score":0.30685282,"_source":{"name" : "john" , "age" : }}]}}[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$ curl -XGET 'http://master:9200/zhouls/user/_search?q=age:28'
{"took":,"timed_out":false,"_shards":{"total":,"successful":,"failed":},"hits":{"total":,"max_score":1.4054651,"hits":[{"_index":"zhouls","_type":"user","_id":"","_score":1.4054651,"_source":{"name" : "john" , "age" : }},{"_index":"zhouls","_type":"user","_id":"","_score":0.30685282,"_source":{"name" : "john" , "age" : }},{"_index":"zhouls","_type":"user","_id":"","_score":0.30685282,"_source":{"name" : "john" , "age" : }}]}}[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$
[hadoop@master elasticsearch-2.4.]$

官网

https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html

Elasticsearch之CURL命令的GET的更多相关文章

  1. Elasticsearch之CURL命令的UPDATE

    对于,Elasticsearch之CURL命令的UPDATE包括局部更新和全部更新.可以去看我写的另一篇博客. Elasticsearch之更新(全部更新和局部更新) 总结: ES全部更新,使用PUT ...

  2. elasticsearch(3) curl命令

    curl 操作http的get/post/put/delete CURL 命令参数-a/--append 上传文件时,附加到目标文件-A/--user-agent <string> 设置用 ...

  3. Elasticsearch之CURL命令的DELETE

    也可以看我写的下面的博客 Elasticsearch之curl删除 Elasticsearch之curl删除索引库 删除,某一条数据,如下 [hadoop@master elasticsearch-] ...

  4. Elasticsearch之CURL命令的mget查询

    我这里, 再,创建一个zhouls2的索引库. [hadoop@master elasticsearch-]$ curl -XPUT 'http://master:9200/zhouls2/' {]$ ...

  5. Elasticsearch之CURL命令的version控制

    普通关系型数据库使用的是(悲观并发控制(PCC)) 当我们在修改一个数据前先锁定这一行,然后确保只有读取到数据的这个线程可以修改这一行数据 ES使用的是(乐观并发控制(OCC)) ES不会阻止某一数据 ...

  6. Elasticsearch之CURL命令的bulk批量操作

    大家,也可去看看我下面的博客 Elasticsearch之批量操作bulk 官网上,是举例了新建一个requests文件. [hadoop@master elasticsearch-]$ pwd /h ...

  7. Elasticsearch之CURL命令的DSL查询

    它是Domain Specific Language领域特定语言. https://www.elastic.co/guide/en/elasticsearch/reference/current/in ...

  8. Elasticsearch之CURL命令的HEAD

    如果只想检查一些文档是否存在,我们可以使用HEAD来替代GET方法,这样就只会返回HTTP头文件. [hadoop@master elasticsearch-]$ curl -i XHEAD http ...

  9. Elasticsearch之CURL命令的PUT和POST对比

    PUT是幂等方法,而POST并不是. PUT用于更新操作,POST用于新增操作比较合适. PUT,DELETE操作是幂等的,所谓幂等就是指不管进行多少次操作,结果都一样. 比如,我用PUT修改一篇文章 ...

随机推荐

  1. Unity高像素截图

    本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接:http://blog.csdn.net/cartzhang/article/details/51386272 作者:car ...

  2. Mozilla新特性只支持https网站

    Mozilla的官方博客2015.4.30正式宣布了淘汰HTTP的方案. 其中包括:设定一个日期,所有的新特性将只提供给HTTPS网站:HTTP网站将逐步被禁止访问浏览器功能,尤其是那些与用户安全和隐 ...

  3. pat甲级 1107. Social Clusters (30)

    When register on a social network, you are always asked to specify your hobbies in order to find som ...

  4. 47. Spring Boot发送邮件【从零开始学Spring Boot】

    (提供源代码) Spring提供了非常好用的JavaMailSender接口实现邮件发送.在Spring Boot的Starter模块中也为此提供了自动化配置.下面通过实例看看如何在Spring Bo ...

  5. hdu 1867 kmp匹配

    #include<stdio.h> #include<string.h> #define N 100100 void getnext(int next[],char s[]) ...

  6. [K/3Cloud]在插件中根据条件取消表单打开过程

    新建一个类,继承自动态表单抽象插件类AbstractBillPlugIn,重写PreOpenForm. /// <summary> /// 销售订单 单据维护界面插件 /// </s ...

  7. 最大公约数GCD

    基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 输入2个正整数A,B,求A与B的最大公约数. Input 2个数A,B,中间用空格隔开.(1<= A,B <= ...

  8. 为 Windows Phone 8.1 app 解决“The type does not support direct content.”的问题

    我在 VS 14 CTP 中新建了一个空的 app store 项目名叫 PlayWithXaml ,项目的 MainPage.xaml 文件改为了以下内容: <Page x:Class=&qu ...

  9. E - 不容易系列之(4)――考新郎 错排数公式

    国庆期间,省城HZ刚刚举行了一场盛大的集体婚礼,为了使婚礼进行的丰富一些,司仪临时想出了有一个有意思的节目,叫做"考新郎",具体的操作是这样的:  首先,给每位新娘打扮得几乎一模一 ...

  10. jd-eclipse插件的安装

    一,资源 jd-eclipse-site-1.0.0-RC2.zip    百度网盘链接:https://pan.baidu.com/s/1GTFFY_1jg4k9vjZNE4JliQ       提 ...