Elasticsearch服务

Elasticsearch服务,第1张

Elasticsearch服务 Elasticsearch下载安装 下载

官网下载地址: https://www.elastic.co/cn/downloads/elasticsearch

安装 windows10

下载解压后需要配置Elasticsearch自带的JDK的环境变量
当前我把Elasticsearch解压到C盘的
ES_JAVA_HOME:C:elasticsearch-7.15.2-windows-x86_64elasticsearch-7.15.2jdk

启动服务:去到解压文件C:elasticsearch-7.15.2-windows-x86_64elasticsearch-7.15.2bin目录下,双击elasticsearch.bat文件

服务启动后访问: http://localhost:9200/

Kibana 下载安装

注意: Kibana 版本要和ElasticSearch版本一致
下载地址: https://www.elastic.co/cn/downloads/kibana

安装

安装参考:https://blog.csdn.net/weixin_34727238/article/details/81200071
下载后解压,双击执行bin目录下的 kibana.bat 批处理文件

服务启动之后,浏览器访问: http://localhost:5601

Elasticsearch *** 作 PostMan *** 作索引

索引相当于关系性数据库中的数据库

### 添加索引
PUT  http://localhost:9200/index_01
### 查询索引
GET http://localhost:9200/index_01
查询所有的索引:-all 是ES 内置的,其他的还有_close、_open
GET http://localhost:9200/_all
### 关闭索引
POST http://localhost:9200/index_01/_close
### 打开索引
POST http://localhost:9200/index_01/_open
### 删除索引
POST http://localhost:9200/index_01
*** 作映射

映射相当于关系性数据库的表结构

"""
数据类型:简单数据类型和复杂数据类型 
	简单数据类型:
		 字符串: 
		 	文本: 支持分词,不支聚合
		 	keywords:不支持分词,支持聚合
		 数值
		 布尔
		 二进制
		 范围
		 日期
	复杂数据类型:
		数组:[]
		对象:{}
"""
Kibana  下 *** 作映射:
	# 创建索引
	PUT person
	
	# 查看索引
	GET person
	GET _all
	# 创建映射
	PUT person/_mapping
	{
	 "properties":{
	    "name":{
	      "type":"text"
	    },
	    "age":{
	      "type":"integer"
	    }
	 }
	}
	
	# 添加映射
	PUT person/_mapping
	{
	  "properties":{
	    "height":{
	      "type": "double"
	    }
	  }
	}
	
	# 查询映射
	GET person/_mapping
	
	# 删除索引
	DELETE person
	
	# 创建索引的时候同时创建映射
	PUT person
	{
	  "mappings":{
	    "properties":{
	      "name":{
	        "type":"text"
	      },
	      "height":{
	        "type":"integer"
	      },
	      "age":{
	        "type":"double"
	      }
	    }
	  }
	}
*** 作文档
GET person
# 创建文档, 不指定ID(只能用post),会随机生成is
POST person/_doc
{
  "name":"张珊",
  "height": 10,
  "age":12.6
}
# 创建文档, 指定ID(可以用post,也可以用put)
PUT person/_doc/02
{
  "name":"张珊02",
  "height": 10,
  "age":12.6
}

# 查询文档
GET person/_search

# 修改文档,修改等同于添加,没有及添加,有就修改

# 删除指定文档
DELETE /person/_doc/GJ3cgH0BralMH-yEbCOr

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/5654993.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存