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 < ...
随机推荐
- git配置文件读取顺序
作者:zhanhailiang 日期:2014-11-03 git包括三个配置文件: /etc/gitconfig 文件:系统中对全部用户都普遍适用的配置. 若使用git config 时用' –sy ...
- shell脚本分析 nginx日志访问次数最多及最耗时的页面
当服务器压力比较大,跑起来很费力时候.我们经常做站点页面优化,会去查找那些页面访问次数比较多,而且比较费时. 找到那些访问次数高,并且比较耗时的地址,就行相关优化,会取得立竿见影的效果的. 下面是我在 ...
- iOS-获取苹果商店iPhone应用程序编号APPID-应用中跳转到AppStore中的其他应用
iOS-获取苹果商店iPhone应用程序编号APPID-应用中跳转到AppStore中的其他应用 一 获取苹果商店iPhone应用程序编号APPID 1 在mac上打开itunes 选择中的A 然后 ...
- UNRECOGNIZED SELECTOR SENT TO INSTANCE 问题快速定位的方法
开发中常见的一类崩溃错误是遇到:unrecognized selector sent to instance 0xaxxxx…而backtrace又无法明确说明错误在哪行代码,如何快速定位BUG呢? ...
- Android开发日记(七)
trim()方法返回调用字符串对象的一个副本,但是所有起始和结尾的空格都被删除了,例子如下:String s=" Hello World ".trim();就是把" ...
- HADOOP 2.6 INSTALLING ON UBUNTU 14.04 (hadoop 2.6 部署到ubuntu 14.04上面)
Hadoop on Ubuntu 14.04 In this chapter, we'll install a single-node Hadoop cluster backed by the Had ...
- FreeRTOS 临界段和开关中断
以下转载自安富莱电子: http://forum.armfly.com/forum.php 临界段代码的临界段也称为临界区,一旦这部分代码开始执行,则不允许任何中断打断.为确保临界段代码的执行不被中断 ...
- LeetCode 70 Climbing Stairs(爬楼梯)(动态规划)(*)
翻译 你正在爬一个楼梯. 它须要n步才干究竟顶部. 每次你能够爬1步或者2两步. 那么你有多少种不同的方法爬到顶部呢? 原文 You are climbing a stair case. It tak ...
- lockf函数的使用
#include<stdio.h> #include<unistd.h> void main() {int p1,p2,i; while((p1=fork())==-1);// ...
- TensorFlow基础笔记(5) VGGnet_test
参考 http://blog.csdn.net/jsond/article/details/72667829 资源: 1.相关的vgg模型下载网址 http://www.vlfeat.org/matc ...