02.Elasticsearch入门
1.Elasticsearch基本概念
2.使用Restful API简单操作ElasticSearch
[lizhiwei@localhost ~]$ curl -XGET http://192.168.110.100:9200{"status" : 200,"name" : "node000","cluster_name" : "elasticsearchTest","version" : {"number" : "1.7.2","build_hash" : "e43676b1385b8125d647f593f7202acbd816e8ec","build_timestamp" : "2015-09-14T09:49:53Z","build_snapshot" : false,"lucene_version" : "4.10.4"},"tagline" : "You Know, for Search"}
[lizhiwei@localhost ElasticSearch]$ curl -XPUT http://192.168.110.100:9200/test -d @data.json{"acknowledged":true}---------------------------------------------data.json内容{"settings" : {"index" : {"number_of_shards" : "4","number_of_replicas" : "2"}}}
[lizhiwei@localhost ElasticSearch]$ curl -XPUT http://192.168.110.100:9200/test -d @data.json{"acknowledged":true}---------------------------------------------data.json内容{"settings" : {"index" : {"number_of_shards" : "4","number_of_replicas" : "1"}},"mappings" : {"DocType001" : {"_source" : {"enabled" : false},"properties" : {"field1" : {"type" : "string","index" : "not_analyzed"},"field2" : {"type" : "string","store" : "yes"}}}}}
[lizhiwei@localhost ElasticSearch]$ curl -XDELETE http://192.168.110.100:9200/test{"acknowledged":true}
[lizhiwei@localhost ElasticSearch]$ curl -XPOST http://192.168.110.100:9200/test/People?pretty -d '{ "tag" : "bad" }'{"_index" : "test","_type" : "People","_id" : "AVBRAKASiFg2t1Ow-SEW","_version" : 1,"created" : true}
[lizhiwei@localhost ElasticSearch]$ curl -XPOST http://192.168.110.100:9200/test/People/3?pretty -d '{ "tag" : "bad" }'{"_index" : "test","_type" : "People","_id" : "3","_version" : 1,"created" : true}
# 查询所有的index和type的记录curl -XGET http://IP:9200/_search?pretty# 查询某个index下所有type的记录curl -XGET http://IP:9200/<index>/_search?pretty# 查询某个index下某个type下所有的记录curl -XGET http://IP:9200/<index>/<type>/_search?pretty# 使用参数查询所有的记录curl -XGET http://IP:9200/_search?q=tag:bad&pretty;# 使用参数查询某个index下的所有记录curl -XGET http://IP:9200/<index>/_search?q=tag:bad&pretty;# 使用参数查询某个index下某个type下所有的记录curl -XGET http://IP:9200/<index>/<type>/_search?q=tag:bad&pretty;# 使用JSON参数查询所有的记录,-d代表一个JSON格式的对象curl -XGET http://IP:9200/_search?pretty -d '{ "query" : { "term" : { "tag" : "bad" } } }'# 使用JSON参数查询某个index下的所有记录curl -XGET http://IP:9200/<index>/_search?pretty -d '{ "query" : { "term" : { "tag" : "bad" } } }'# 使用JSON参数查询某个index下某个type下所有的记录curl -XGET http://IP:9200/<index>/<type>/_search?pretty -d '{ "query" : { "term" : { "tag" : "bad" } } }'
[lizhiwei@localhost ElasticSearch]$ curl -XGET http://192.168.110.100:9200/test/People/_search?pretty{"took" : 4,"timed_out" : false,"_shards" : {"total" : 5,"successful" : 5,"failed" : 0},"hits" : {"total" : 2,"max_score" : 1.0,"hits" : [ {"_index" : "test","_type" : "People","_id" : "AVBRBKcOiFg2t1Ow-SEy","_score" : 1.0,"_source":{ "tag" : "bad" }}, {"_index" : "test","_type" : "People","_id" : "3","_score" : 1.0,"_source":{ "tag" : "bad" }} ]}}
[lizhiwei@localhost ElasticSearch]$ curl -XPUT http://192.168.110.100:9200/test/People/3?pretty -d '{ "tag" : "good" }'{"_index" : "test","_type" : "People","_id" : "3","_version" : 3,"created" : false}
[lizhiwei@localhost ElasticSearch]$ curl -XDELETE http://192.168.110.100:9200/test/People/3?pretty{"found" : true,"_index" : "test","_type" : "People","_id" : "3","_version" : 4}
[lizhiwei@localhost ElasticSearch]$ curl -XGET http://192.168.110.100:9200/_cluster/health?pretty{"cluster_name" : "elasticsearchTest","status" : "green","timed_out" : false,"number_of_nodes" : 4,"number_of_data_nodes" : 4,"active_primary_shards" : 7,"active_shards" : 14,"relocating_shards" : 0,"initializing_shards" : 0,"unassigned_shards" : 0,"delayed_unassigned_shards" : 0,"number_of_pending_tasks" : 0,"number_of_in_flight_fetch" : 0}
3.常用的Restful API
# 检查集群健康:curl -XGET http://127.0.0.1:9200/_cluster/health?pretty# 关闭整个集群:curl -XPOST http://127.0.0.1:9200/_cluster/nodes/_shutdown# 关闭单台节点:curl -XPOST http://127.0.0.1:9200/_cluster/nodes/{node.name}/_shutdown# 查看集群节点:curl -XGET http://127.0.0.1:9200/_cluster/nodes?pretty# 查看集群状态:curl -XGET http://127.0.0.1:9200/_cluster/state?pretty# 查看节点状态:curl -XGET http://127.0.0.1:9200/_nodes/stats?pretty# 查看本机节点:curl -XGET http://127.0.0.1:9200/_nodes/_local?pretty# 查看集群节点信息:curl -XGET http://127.0.0.1:9200/_cluster/state/nodes# 查看索引映射:curl -XGET http://127.0.0.1:9200/.marvel-kibana/_mapping?pretty以上所有查询都可以针对json节点的子节点进行查询,关键词如:settings, os, process, jvm, thread_pool, network, transport, http , plugins例如:curl -XGET 'http://localhost:9200/_nodes?pretty'curl -XGET 'http://localhost:9200/_nodes/process?pretty'curl -XGET 'http://localhost:9200/_nodes/os?pretty'curl -XGET 'http://localhost:9200/_nodes/settings?pretty'
-------------------------------------------------------------------------------------------------------------------------------
02.Elasticsearch入门的更多相关文章
- 《读书报告 -- Elasticsearch入门 》-- 安装以及简单使用(1)
<读书报告 – Elasticsearch入门 > 第一章 Elasticsearch入门 Elasticsearch是一个实时的分布式搜索和分析引擎,使得人们可以在一定规模上和一定速度上 ...
- 全文搜索引擎Elasticsearch入门实践
全文搜索引擎Elasticsearch入门实践 感谢阮一峰的网络日志全文搜索引擎 Elasticsearch 入门教程 安装 首先需要依赖Java环境.Elasticsearch官网https://w ...
- springboot整合elasticsearch入门例子
springboot整合elasticsearch入门例子 https://blog.csdn.net/tianyaleixiaowu/article/details/72833940 Elastic ...
- ElasticSearch入门-搜索如此简单
搜索引擎我也不是很熟悉,但是数据库还是比较了解.可以把搜索理解为数据库的like功能的替代品.因为like有以下几点不足: 第一.like的效率不行,在使用like时,一般都用不到索引,除非使用前缀匹 ...
- ElasticSearch入门知识扫盲
ElasticSearch 入门介绍 tags: 第三方 lucene [toc] 1. what Elastic Search(ES)是什么 全文检索和lucene 全文检索 优点:高效,准确,分词 ...
- 《读书报告 -- Elasticsearch入门 》--简单使用(2)
<读书报告 – Elasticsearch入门 > ' 第四章 分布式文件存储 这章的主要内容是理解数据如何在分布式系统中存储. 4.1 路由文档到分片 创建一个新文档时,它是如何确定应该 ...
- ElasticSearch入门 附.Net Core例子
1.什么是ElasticSearch? Elasticsearch是基于Lucene的搜索引擎.它提供了一个分布式,支持多租户的全文搜索引擎,它具有HTTP Web界面和无模式JSON文档. Elas ...
- ElasticSearch入门点滴
这是Elasticsearch-6.2.4 版本系列的第一篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 ...
- Elasticsearch Elasticsearch入门指导
Elasticsearch入门指导 By:授客 QQ:1033553122 1. 开启elasticsearch服务器 1 2. 基本概念 2 <1> 集群(Cluster) 2 < ...
随机推荐
- MySQL主从配置的一些总结
有很多朋友做了mysql主从也有一段时间了,但是有时候也走了不少弯路,时间也浪费了不少,主要问题是没有查阅其他的主机配置的相关资料,而仅仅是看了配置文档,下面是作者对主从配置的一些总结. AD: 20 ...
- Mongodb与mysql语法比较
Mongodb与mysql语法比较 mongodb与mysql命令对比 传统的关系数据库一般由数据库(database).表(table).记录(record)三个层次概念组成,MongoDB是由 ...
- unity, 欧拉角(euler angle)
1,按ZXY顺序. 2,左手螺旋. 3,Z,X,Y旋转均应以未旋转前的坐标系为准.
- [转]winform程序textbox滚动条保持在最下面 内容不闪烁
在开发winform程序时,会用到textbox控件来显示信息,当把textbox的Multiline属性改为Ture时(即多行显示状态),ScrollBars属性改为Vertical(内容过多时,显 ...
- 【Android】15.3 Notification基础知识
分类:C#.Android.VS2015: 创建日期:2016-02-29 一.如何向用户发出通知 1.使用Toast通知用户 前台任务中的通知(Notifications)一般用于长时间显示用户正在 ...
- IOS 获取设备屏幕的尺寸
// 不包含状态栏 CGRect rect1 = [UIScreen mainScreen].applicationFrame; // 包含状态栏(整个屏幕) CGRect rect2 = [[UIS ...
- Java Mail(一):telnet实现发送收取邮件
http://blog.csdn.net/ghsau/article/details/8602076 ******************************* 最近要做一个解析邮件的东东,就顺便 ...
- onResume
比如做一个音乐播放程序,在播放过程中,突然有电话打进来了,这时系统自动调出电话,而你的音乐播放程序置于后台,触发了onPause方法.当你电话结束后,关闭电话,又自动回到音乐播放程序,此时,触发onR ...
- FreeRtos——任务删除,改变任务优先级
以下转载自安富莱电子: http://forum.armfly.com/forum.php vTaskDelete() API 函数任务可以使用 API 函数 vTaskDelete()删除自己或其它 ...
- hdu1428(记忆化搜索)
题意:“他考虑从A区域到B区域仅当存在一条从B到机房的路线比任何一条从A到机房的路线更近(否则可能永远都到不了机房了…”这句话一定要理解清楚.就是说,对于当前位置,如果下一个状态与终点的最短距离大于或 ...