Elasticsearch之CURL命令的GET
这是个查询命令。
前期博客
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的更多相关文章
- Elasticsearch之CURL命令的UPDATE
对于,Elasticsearch之CURL命令的UPDATE包括局部更新和全部更新.可以去看我写的另一篇博客. Elasticsearch之更新(全部更新和局部更新) 总结: ES全部更新,使用PUT ...
- elasticsearch(3) curl命令
curl 操作http的get/post/put/delete CURL 命令参数-a/--append 上传文件时,附加到目标文件-A/--user-agent <string> 设置用 ...
- Elasticsearch之CURL命令的DELETE
也可以看我写的下面的博客 Elasticsearch之curl删除 Elasticsearch之curl删除索引库 删除,某一条数据,如下 [hadoop@master elasticsearch-] ...
- Elasticsearch之CURL命令的mget查询
我这里, 再,创建一个zhouls2的索引库. [hadoop@master elasticsearch-]$ curl -XPUT 'http://master:9200/zhouls2/' {]$ ...
- Elasticsearch之CURL命令的version控制
普通关系型数据库使用的是(悲观并发控制(PCC)) 当我们在修改一个数据前先锁定这一行,然后确保只有读取到数据的这个线程可以修改这一行数据 ES使用的是(乐观并发控制(OCC)) ES不会阻止某一数据 ...
- Elasticsearch之CURL命令的bulk批量操作
大家,也可去看看我下面的博客 Elasticsearch之批量操作bulk 官网上,是举例了新建一个requests文件. [hadoop@master elasticsearch-]$ pwd /h ...
- Elasticsearch之CURL命令的DSL查询
它是Domain Specific Language领域特定语言. https://www.elastic.co/guide/en/elasticsearch/reference/current/in ...
- Elasticsearch之CURL命令的HEAD
如果只想检查一些文档是否存在,我们可以使用HEAD来替代GET方法,这样就只会返回HTTP头文件. [hadoop@master elasticsearch-]$ curl -i XHEAD http ...
- Elasticsearch之CURL命令的PUT和POST对比
PUT是幂等方法,而POST并不是. PUT用于更新操作,POST用于新增操作比较合适. PUT,DELETE操作是幂等的,所谓幂等就是指不管进行多少次操作,结果都一样. 比如,我用PUT修改一篇文章 ...
随机推荐
- 分布式数据库中CAP原理(CAP+BASE)
分布式数据库中CAP原理(CAP+BASE) 传统的ACID 1)原子性(Atomicity): 事务里的所有操作要么全部做完,要么都不做,事务成功的条件是事务里的所有操作都成功. 2)一致性(Con ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- hdu 2602 简单0-1背包模板题
#include<stdio.h> #include<string.h> #define N 1100 int dp[N]; int main() { int n,t,m,a[ ...
- url处理函数
function UrlOption(url) { this.url = url || ''; this.init(); this.change = function (url) { this.url ...
- Android百度地图SDK 导航初始化和地图初始化引起的冲突
如题,相同是百度地图SDK开发过程中遇到的一个问题.交代下背景: 开发了一款内嵌百度地图的应用,因此里面差点儿相同将眼下百度地图SDK开放的主要功能都用到了,定位,地图显示,覆盖物标示.POI搜索,行 ...
- MAC Wireshark抓包IOS
网络抓包是个基础技能,对于网络协议的掌握有一定的要求.iOS上实现网络抓包可以用Charles(针对http和https),tcpdump(快速分析网络包),和Wireshare.之前写过一篇介绍tc ...
- input屏蔽历史记录 ;function($,undefined) 前面的分号是什么用处 JSON 和 JSONP 两兄弟 document.body.scrollTop与document.documentElement.scrollTop兼容 URL中的# 网站性能优化 前端必知的ajax 简单理解同步与异步 那些年,我们被耍过的bug——has
input屏蔽历史记录 设置input的扩展属性autocomplete 为off即可 ;function($,undefined) 前面的分号是什么用处 ;(function($){$.ex ...
- 【Android】资源系列(一) -- 国际化(多语言)
1.Android 中要实现国际化比較简单. 字符串国际化:仅仅要在 res 目录下新建相应语言的 values 目录就好了. 如.英语环境下的.目录命名为:values-en ...
- C/C++ 答疑解问
1. sizeof(string)的大小 string属于类,类的大小就是类中成员变量(非静态)加上指向虚函数表的指针以及指向虚基类表的指针加起来的和.因为string是一个模板类,受具体的实现来决定 ...
- ArcGIS Runtime SDK for iOS中获取ImageServiceLayer的栅格值
本文原创,转载请注明原创地址 http://blog.csdn.net/dongyu1009/article/details/37697389 用AGSImageServiceIdentifyTask ...