ElasticSearch介绍、简单安装

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jiyang_1/article/details/79253972

一  ElasticSearch 介绍

  1. 基于Apache Lucene 构建的开源搜索引擎。
  2. 采用java编写,提供简单易用的Restful API。
  3. 易于横向扩展,可支持PB的结构化数据和非结构化数据。

二 ElasticSearch 安装

下载ElasticSearch软件网址:https://www.elastic.co/downloads/elasticsearch

启动ElasticSearch bin/elasticsearch.bat,启动成功如下图


ElasticSearch可视化工具插件安装elasticsearch-head,下载网址:https://github.com/mobz/elasticsearch-head

启动elasticsearch-head,cmd窗口进入elasticsearch-head,

输入:npm install

启动:npm run start

配置ElasticSearch文件(路径:elasticsearch-6.1.3\config\elasticsearch.yml)


ElasticSearch分布式安装配置:





启动elasticSearch-head,成功界面如下:


至此,ElasticSearch启动成功。

三 简单使用

索引:含有相同属性的文档集合。

类型:索引可以定义一个或者多个类型,文档必须属于一个类型。

文档:文档是可以被索引的基本数据单温。

1、建立索引:

{
	"settings": {
		"number_of_shards": 3,
		"number_of_replicas": 1
	},
	"mappings": {
		"man": {
			"properties": {
				"name": {
					"type": "text"
				},
				"country": {
					"type": "keyword"
				},
				"age": {
					"type": "integer"
				},
				"date": {
					"type": "date",
					"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
				}
			}
		}
	}
}
可以在elasticSearch-head中的复合查询中创建,也可以使用postman工具。

2、elasticSearch的增删改查

Restful API基本格式:http://<ip>:<port>/<索引>/<类型>/<文档id>

常用的四种请求方式:GET、PUT、POST、DELETE

 PUT: 创建索引和文档增加

 POST: 文档增加、查询索引和文档修改

 GET: 查询文档

 DELETE: 删除文档和删除索引


猜你喜欢

转载自blog.csdn.net/jiyang_1/article/details/79253972