文档章节

elasticsearch

十一月不远
 十一月不远
发布于 2014/04/30 14:54
字数 701
阅读 554
收藏 1

#Elasticsearch#

##下载安装##

##体验##

  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

  1. 浏览器输入: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"
}

说明安装成功。

  1. 索引和检索
 //索引,单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)

© 著作权归作者所有

上一篇: elasticsearch
下一篇: Linux 文件目录
十一月不远

十一月不远

粉丝 37
博文 78
码字总数 61436
作品 1
海淀
程序员
私信 提问
CentOS7 部署 ElasticSearch 集群

环境 主机名 IP 操作系统 ES 版本 es227 192.168.1.227 CentOS7.5 6.5.4 es228 192.168.1.228 CentOS7.5 6.5.4 es229 192.168.1.229 CentOS7.5 6.5.4 下载 elasticsearch-6.5.4.tar.gz --- 各......

俊赛潘安-才比管乐
2018/12/27
466
0
k8s helm efk 问题

[root@master03 ~]# kubectl logs -n efk efk-es-elasticsearch-client-786d9b46c9-cmn2w OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and......

weir2016
09/10
141
2
Elasticsearch存储空间不够导致索引只读的解决方法

问题描述 今天发现当天的索引在ES中并没有创建,logstash中不停的报错: 索引变成了只读: es报错,es报错也是索引只读错误 解决办法 经过分析,发现是因为ES所在服务器磁盘空间太低引起,具...

傲娇字符
01/17
1K
0
block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];

[2019-06-19T16:54:52,915][WARN ][r.suppressed ] [node-1] path: /_cat/indices, params: {v=} org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [SERVICE_UNAVAILABL......

打杂uu
06/19
593
0
蛋疼的ElasticSearch(三)之配置elasticsearch-analysis-ik和集群

配置elasticsearch-analysis-ik 1.下载https://github.com/medcl/elasticsearch-analysis-ik 2.解压 elasticsearch-analysis-ik-master.zip 3.mvn clean package 4.打开编译targetreleases,......

cmazxiaoma
2018/10/23
0
0

没有更多内容

加载失败,请刷新页面

加载更多

最简单的获取相机拍照的图片

  import android.content.Intent;import android.graphics.Bitmap;import android.os.Bundle;import android.os.Environment;import android.provider.MediaStore;import andr......

MrLins
26分钟前
4
0
说好不哭!数据可视化深度干货,前端开发下一个涨薪点在这里~

随着互联网在各行各业的影响不断深入,数据规模越来越大,各企业也越来越重视数据的价值。作为一家专业的数据智能公司,个推从消息推送服务起家,经过多年的持续耕耘,积累沉淀了海量数据,在...

个推
28分钟前
7
0
第三方支付-返回与回调注意事项

不管是支付宝,微信,还是其它第三方支付,第四方支付,支付机构服务商只要涉及到钱的交易都要进行如下校验,全部成功了才视为成功订单 1.http请求是否成功 2.校验商户号 3.校验订单号及状态...

Shingfi
31分钟前
4
0
简述Java内存分配和回收策略以及Minor GC 和 Major GC(Full GC)

内存分配: 1. 栈区:栈可分为Java虚拟机和本地方法栈 2. 堆区:堆被所有线程共享,在虚拟机启动时创建,是唯一的目的是存放对象实例,是gc的主要区域。通常可分为两个区块年轻代和年老代。更...

DustinChan
36分钟前
6
0
Excel插入批注:可在批注插入文字、形状、图片

1.批注一直显示:审阅选项卡-------->勾选显示批注选项: 2.插入批注快捷键:Shift+F2 组合键 3.在批注中插入图片:鼠标右键点击批注框的小圆点【重点不可以在批注文本框内点击】----->调出批...

东方墨天
今天
6
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部