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 < ...
随机推荐
- Apache多虚拟主机多版本PHP(5.2+5.3+5.4)共存运行配置全过程
因为某种需求,可能是因为早期的项目需要低版本的php,和目前开发所用的版本不太一致,我们需要给不同的虚拟主机配置不同版本的PHP.避免去额外配置多个Apache,等iis和apache共存的麻烦. 下 ...
- Informix 配置选项
下表列出了用于改善数据库性能的附加选项.如果选择在 onconfig 配置文件中进行更改,则需要重新启动 Informix 通用服务器.可以在 Informix 服务器处于联机或脱机状态时编辑 onc ...
- CUGBACM Codeforces Tranning 3 题解
链接:http://acm.hust.edu.cn/vjudge/contest/view.action? cid=62515#overview 描写叙述:第三场CF训练了.这次做的挺搞笑的,我记得这 ...
- **alon_MM DMA Interface for PCIe使用详解
在所从事的项目中需要用到PCIE和DMA,经过再三研究,反复查看相关资料,终于弄懂了**alon_MM DMA Interface for PCIe的使用方法. PCIE在fpga和上位机之间起着中间 ...
- 【ecshop后台详解】系统设置-商店设置
商店设置是我们ecshop新用户第一步先要设置的地方,因为里面相当于网站的基础.包括公司名称,电话,地址,tittle等重要的信息都是这里修改,如果这里没有修改的话,如果有访客来到你网站可能以为走错了 ...
- 关于 initWithNibName 和 loadNibNamed 的区别和联系-iPhone成长之路
转自:http://blog.sina.com.cn/s/blog_7b9d64af01018f2u.html 关于 initWithNibName 和 loadNibNamed 的区别和联系.之所以 ...
- ov5640 video capture时,vfe_v4l2.ko模块挂掉问题分析
1.问题描述 在r16 tina平台,基于ov5640获取摄像头数据时,vfe_v4l2.ko模块挂掉. 2.配置信息 2.1上层应用设置的像素格式为V4L2_PIX_FMT_YUYV,分辨率为480 ...
- poj 2524 Ubiquitous Religions 一简单并查集
Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 22389 Accepted ...
- chrome 插件地址 知乎
chrome运行内存过大:https://www.zhihu.com/question/20061319 chrome扩展程序:https://www.zhihu.com/question/19594 ...
- java POi excel 写入大批量数据
直接贴代码: package jp.co.misumi.mdm.batch.common.jobrunner; import java.io.File; import java.io.FileNotF ...