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 < ...
随机推荐
- sql server数据库查询超时报错
报错信息如下: 链接服务器"DBJointFrame"的 OLE DB 访问接口 "SQLNCLI10" 返回了消息 "查询超时已过期". ...
- Atitit.网页爬虫的架构总结
Atitit.网页爬虫的架构总结 1. 总数的结构..(接口方法) 1 2. 获得页数 1 3. 跳页处理(接口方法) 2 4. 单个的页面处理(接口方法) 2 4.1. 获得页面url 3 4.2. ...
- quick cocos2d-x 2.2.4 window环境调试
BabeLua简介 BabeLua是一款基于VS2012/2013(简称VS)的免费开源的Lua集成开发环境,在Lua编辑和调试方面,具有如下功能和特性: ●Lua语法高亮 ●语法检查 ●自动补全 ● ...
- UITableView__cell 距tableview顶端有间距
UITableView__cell 距tableview顶端有间距 如何去掉这个间距呢?解决方法如下: //top 为cell距顶端的间距 (一般为负值) self.formTable.con ...
- vue2.0实现图片加载失败默认显示图片
<div class="bg"> <img :src="goods.phoneFloorAd.resUrl" :onerror="e ...
- 错误:undefined reference to `__gxx_personality_v0'
使用gcc编译C代码,引用了C++ 库,出现这个错误,网上搜到这哥们的文章,解决问题 转自:错误:undefined reference to `__gxx_personality_v0' 1. Li ...
- CSS 框架之 Bootstrap 的下载和安装
BootStrap 简介: Bootstrap 是一个用于快速开发 Web 应用程序和网站的前端框架.Bootstrap 是基于 HTML.CSS.JAVASCRIPT 的. 响应式设计:Bootst ...
- 连接数据库通过配置文件app.config
ConfigurationManager类 public static class ConfigurationManager 命名空间: System.Configuration 程序集: Syste ...
- Spring MVC之@RequestParam @RequestBody @RequestHeader 等详解<转>
简介: handler method 参数绑定常用的注解,我们根据他们处理的Request的不同内容部分分为四类:(主要讲解常用类型) A.处理requet uri 部分(这里指uri templat ...
- Entity Framework中的实体类添加复合主键
使用Code First模式实现给实体类添加复合主键,代码如下: using System; using System.Collections.Generic; using System.Compon ...