Elasticsearch
2014-04-30 15:00
232 查看
#Elasticsearch#
##下载安装##
+ 下载地址http://www.elasticsearch.org/overview/elkdownloads/
+ 安装:解压即可
##体验##
1. 在解压目录运行:
```
./bin/elasticsearch
[2014-04-30 14:07:13,930][INFO ][node ] [Roma] version[1.1.1], pid[7262], build[f1585f0/2014-04-16T14:27:12Z]
[2014-04-30 14:07:13,931][INFO ][node ] [Roma] initializing ...
[2014-04-30 14:07:13,958][INFO ][plugins ] [Roma] loaded [], sites []
[2014-04-30 14:07:16,993][INFO ][node ] [Roma] initialized
[2014-04-30 14:07:16,993][INFO ][node ] [Roma] starting ...
[2014-04-30 14:07:17,211][INFO ][transport ] [Roma] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.20.152:9300]}
[2014-04-30 14:07:20,294][INFO ][cluster.service ] [Roma] new_master [Roma][HHJEbKWSSPWKb6fL7yl1bA][XXX(**主机名保密)][inet[/192.168.20.152:9300]], reason: zen-disco-join (elected_as_master)
[2014-04-30 14:07:20,374][INFO ][discovery ] [Roma] elasticsearch/HHJEbKWSSPWKb6fL7yl1bA
[2014-04-30 14:07:20,420][INFO ][http ] [Roma] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.20.152:9200]}
[2014-04-30 14:07:20,463][INFO ][gateway ] [Roma] recovered [0] indices into cluster_state
[2014-04-30 14:07:20,465][INFO ][node ] [Roma] started
```
2. 浏览器输入:http://localhost:9200/
```
{
"status" : 200,
"name" : "Roma",
"version" : {
"number" : "1.1.1",
"build_hash" : "f1585f096d3f3985e73456debdc1a0745f512bbc",
"build_timestamp" : "2014-04-16T14:27:12Z",
"build_snapshot" : false,
"lucene_version" : "4.7"
},
"tagline" : "You Know, for Search"
}
```
说明安装成功。
3. 索引和检索
```
//索引,单field
curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{"name":"Shay Banon"}'
{"_index":"twitter","_type":"user","_id":"kimchy","_version":1,"created":true}
//索引,多field
curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}'
{"_index":"twitter","_type":"tweet","_id":"1","_version":1,"created":true}
//索引,url里面的id和上面不一样
curl -XPUT http://localhost:9200/twitter/tweet/2 -d '{"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for Search"}'
{"_index":"twitter","_type":"tweet","_id":"2","_version":1,"created":true}
//获取数据
curl -XGET http://localhost:9200/twitter/tweet/2
{"_index":"twitter","_type":"tweet","_id":"2","_version":1,"found":true, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for Search"}}
//lucence语法方式查询
curl -XGET http://localhost:9200/twitter/tweet/_search?q=user:kimchy
{"took":68,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"twitter","_type":"tweet","_id":"2","_score":1.0, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You
know,for Search"}},{"_index":"twitter","_type":"tweet","_id":"1","_score":0.30685282, "_source" : {"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}}]}}
//query DSL 方式查询
curl -XGET http://localhost:9200/twitter/tweet/_search -d '{"query":{"term":{"user":"kimchy"}}}'
{"took":6,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"twitter","_type":"tweet","_id":"2","_score":1.0, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for
Search"}},{"_index":"twitter","_type":"tweet","_id":"1","_score":0.30685282, "_source" : {"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}}]}}
//query DSL 方式查询,结果美化
curl -XGET http://localhost:9200/twitter/_search?pretty=true -d '{"query":{"range":{"post_date":{"from":"2001-10-01T10:00:00","to":"2014-12-10T10:20:20"}}}}'
{
"took" : 19,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "2",
"_score" : 1.0, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for Search"}
}, {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_score" : 1.0, "_source" : {"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}
} ]
}
}
```
##特点##
+ 模式自由(Schema Free)& 面向文档的(Document Oriented)
+ 模式映射(Schema Mapping)
+ 获取数据(Geting Some Data)
+ 搜索(Search)
+ 多租户(Multi Tanancy)
+ 设置(Settings)
+ 分布式(Distributed)
+ 冗灾恢复(Gateway)
##下载安装##
+ 下载地址http://www.elasticsearch.org/overview/elkdownloads/
+ 安装:解压即可
##体验##
1. 在解压目录运行:
```
./bin/elasticsearch
[2014-04-30 14:07:13,930][INFO ][node ] [Roma] version[1.1.1], pid[7262], build[f1585f0/2014-04-16T14:27:12Z]
[2014-04-30 14:07:13,931][INFO ][node ] [Roma] initializing ...
[2014-04-30 14:07:13,958][INFO ][plugins ] [Roma] loaded [], sites []
[2014-04-30 14:07:16,993][INFO ][node ] [Roma] initialized
[2014-04-30 14:07:16,993][INFO ][node ] [Roma] starting ...
[2014-04-30 14:07:17,211][INFO ][transport ] [Roma] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.20.152:9300]}
[2014-04-30 14:07:20,294][INFO ][cluster.service ] [Roma] new_master [Roma][HHJEbKWSSPWKb6fL7yl1bA][XXX(**主机名保密)][inet[/192.168.20.152:9300]], reason: zen-disco-join (elected_as_master)
[2014-04-30 14:07:20,374][INFO ][discovery ] [Roma] elasticsearch/HHJEbKWSSPWKb6fL7yl1bA
[2014-04-30 14:07:20,420][INFO ][http ] [Roma] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.20.152:9200]}
[2014-04-30 14:07:20,463][INFO ][gateway ] [Roma] recovered [0] indices into cluster_state
[2014-04-30 14:07:20,465][INFO ][node ] [Roma] started
```
2. 浏览器输入:http://localhost:9200/
```
{
"status" : 200,
"name" : "Roma",
"version" : {
"number" : "1.1.1",
"build_hash" : "f1585f096d3f3985e73456debdc1a0745f512bbc",
"build_timestamp" : "2014-04-16T14:27:12Z",
"build_snapshot" : false,
"lucene_version" : "4.7"
},
"tagline" : "You Know, for Search"
}
```
说明安装成功。
3. 索引和检索
```
//索引,单field
curl -XPUT http://localhost:9200/twitter/user/kimchy -d '{"name":"Shay Banon"}'
{"_index":"twitter","_type":"user","_id":"kimchy","_version":1,"created":true}
//索引,多field
curl -XPUT http://localhost:9200/twitter/tweet/1 -d '{"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}'
{"_index":"twitter","_type":"tweet","_id":"1","_version":1,"created":true}
//索引,url里面的id和上面不一样
curl -XPUT http://localhost:9200/twitter/tweet/2 -d '{"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for Search"}'
{"_index":"twitter","_type":"tweet","_id":"2","_version":1,"created":true}
//获取数据
curl -XGET http://localhost:9200/twitter/tweet/2
{"_index":"twitter","_type":"tweet","_id":"2","_version":1,"found":true, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for Search"}}
//lucence语法方式查询
curl -XGET http://localhost:9200/twitter/tweet/_search?q=user:kimchy
{"took":68,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"twitter","_type":"tweet","_id":"2","_score":1.0, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You
know,for Search"}},{"_index":"twitter","_type":"tweet","_id":"1","_score":0.30685282, "_source" : {"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}}]}}
//query DSL 方式查询
curl -XGET http://localhost:9200/twitter/tweet/_search -d '{"query":{"term":{"user":"kimchy"}}}'
{"took":6,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":2,"max_score":1.0,"hits":[{"_index":"twitter","_type":"tweet","_id":"2","_score":1.0, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for
Search"}},{"_index":"twitter","_type":"tweet","_id":"1","_score":0.30685282, "_source" : {"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}}]}}
//query DSL 方式查询,结果美化
curl -XGET http://localhost:9200/twitter/_search?pretty=true -d '{"query":{"range":{"post_date":{"from":"2001-10-01T10:00:00","to":"2014-12-10T10:20:20"}}}}'
{
"took" : 19,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 2,
"max_score" : 1.0,
"hits" : [ {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "2",
"_score" : 1.0, "_source" : {"user":"kimchy","post_date":"2014-05-12T13:13:00","message":"You know,for Search"}
}, {
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_score" : 1.0, "_source" : {"user":"kimchy","post_date":"2014-04-12T13:13:00","message":"Trying out elasticsearch,so far so good?"}
} ]
}
}
```
##特点##
+ 模式自由(Schema Free)& 面向文档的(Document Oriented)
+ 模式映射(Schema Mapping)
+ 获取数据(Geting Some Data)
+ 搜索(Search)
+ 多租户(Multi Tanancy)
+ 设置(Settings)
+ 分布式(Distributed)
+ 冗灾恢复(Gateway)
相关文章推荐
- 巧用mysql提示符prompt清晰管理数据库的方法
- 两大步骤教您开启MySQL 数据库远程登陆帐号的方法
- phpmyadmin 4+ 访问慢的解决方法
- linux系统下实现mysql热备份详细步骤(mysql主从复制)
- CentOS 5.5下安装MySQL 5.5全过程分享
- MySQL复制的概述、安装、故障、技巧、工具(火丁分享)
- ElasticSearch的学习资源
- elasticsearch基本概念
- Elasticsearch Java虚拟机配置详解(转)
- 一些国外优秀的elasticsearch使用案例
- Solr4.0(SolrCloud) & ElasticSearch(ES) 比较(三):查询方式(query_then_fetch)
- Elasticsearch 1.0.0 GA于2014年2月12日正式发布
- ElasticSearch的shard迁移
- ElasticSearch的gateway分析
- 使用logstash+elasticsearch+kibana快速搭建日志平台
- ElasticSearch
- ElasticSearch使用
- 全文搜索引擎Elasticsearch的安装过程
- ElasticSearch插件安装---Head ,Kopf与Bigdesk
- Centos7.3部署Elasticsearch5.4.0集群