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 < ...
随机推荐
- centos-7 charpter one
一.system locale 的介绍: 系统的区域设置被保存在/etc/locale.conf 这个文件中,systemd在启动的时候会去读取它:所有用户和程序的区域设置都继承自它, 当然用户&am ...
- unity, 内置shader下载地址
在unity的download页面上能找到Built in shaders的下载连接.
- AngularJS 中 Provider 的用法及区别
在一个分层良好的 Angular 应用中,Controller 这一层应该很薄.也就是说,应用里大部分的业务逻辑和持久化数据都应该放在 Service 里. 为此,理解 AngularJS 中的几个 ...
- 在ubuntu下安装free pascal
1.ubuntu16.04版本已经集成了free pascal最新的3.0版,只需要安装就可以了. sudo apt install fp-compiler 在ubuntu里面,fp-compiler ...
- [svc]ssh生成key不交互
ssh-keygen -t rsa -f ~/.ssh/id_rsa -P "" 首次执行不交互 第二次再次执行会让输入y
- Path相关方法解说(二)
今天咱们一起来看看Path里 XXXTo 相关的一类方法. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/4 ...
- python 使用urllib.urlopen超时问题的解决方法
准备写一个python脚本抓取网页数据,前面抓了几个都没有什么问题,但总会抓取不完整,在中间过程中没有反应,发现执行urlopen的地方总是提示超时,百度了一下,因为我使用的是urllib不是urll ...
- 03、矢量图形查询工具(Symbol Unicode)
目前的软件开发中,很多地方都使用到了矢量图标,在 Metro app 的开发中,可以使用 Windows 系统图标(02.Universal app 中按钮图标使用 ),包括 Segoe UI Sym ...
- Ubuntu 文件文件夹查看权限和设置权限
ubuntu下查看权限的命令为: ls -l filename ls -ld folder ubuntu下设置权限的命令为: 一共有10位数 其中: 最前面那个 - 代表的是类型 中间那三个 rw- ...
- strerror和perror函数详解
/*#include <string.h> char *strerror(int errnum); 它返回errnum的值所对应的错误提示信息,例如errnum等于12的话,它就会返回&q ...