ElectricSearch 及其head插件windows安装

1.安装ElectricSearch

1,从官方下载中心 ElasticSearch Download 下载ElasticSearch安装包,

2,将zip文件解压到D盘,进入 D:\elasticsearch-6.3.5\bin 目录,双击执行 elasticsearch.bat,该脚本文件执行 ElasticSearch 启动程序

3,打开浏览器,输入 http://localhost:9200 ,显式以下画面,说明ES安装成功

    ​{

  "name": "oD6k3LK",

  "cluster_name": "elasticsearch",

  "cluster_uuid": "VINcOIJ8Q2aK5j5aIb9paQ",​

  "version": {

    "number": "6.5.4",

    "build_flavor": "default",

    "build_type": "zip",

    "build_hash": "d2ef93d",

    "build_date": "2018-12-17T21:17:40.758843Z",

    "build_snapshot": false,

    "lucene_version": "7.5.0",

    "minimum_wire_compatibility_version": "5.6.0",

    "minimum_index_compatibility_version": "5.0.0"

  },

  "tagline": "You Know, for Search"

}

 

 

  2.安装Head插件  

 

为了便于管理ES,可使用head插件,这是最初级的管理工具,在浏览器中显示ES集群,索引等信息,十分简便好用。 

1, 首先要安装Nodejs,下载地址:https://nodejs.org/en/

2, 解压  elasticsearch-head-master 到 D:\elasticsearch-6.3.5\elasticsearch-head-master

3, 配置 elasticsearch-6.3.1\config\elasticsearch.yml

 

# 设成0.0.0.0让任何人都可以访问,线上服务不要这样设置。
network.host: 0.0.0.0http.port: 9200

# 解决elasticsearch-head 集群健康值: 未连接问题(跨域)
http.cors.enabled: true
http.cors.allow-origin: "*"

4, 在elasticsearch-head-master目录下执行 npm install -g grunt-cli

grunt 是基于Node.js的项目构建工具,可以进行打包压缩、测试、执行等等的工作,head插件就是通过grunt启动。

5, 在elasticsearch-head-master目录下执行npm install 安装依赖

6, 修改elasticsearch-head-master配置。

修改服务器监听地址:Gruntfile.js  

   connect: {
            server: {
                options: {          
                   port: 9100,
                    base: '.',
                    keepalive: true,         
                    hostname: '*'
                }
            }
        }

7, 启动运行head服务, 执行 grunt server 命令。

8, 访问head管理页面,地址:http://localhost:9100/   

至此,已安装完成。

3.配置EalsticSearch为Windows服务

切换到ElasticSearch的bin目录执行相应命令:

安装     elasticsearch-service.bat install

删除     elasticsearch-service.bat remove

启动     elasticsearch-service.bat start

停止     elasticsearch-service.bat stop

 

下载链接:

https://pan.baidu.com/s/1yv9lg8WOvSxlb2BO0kAI0w 提取码:l6vK

在Elasticsearch中,文档归属于一种类型(type),而这些类型存在于索引(index)中,我们可以画一些简单的对比图来类比传统关系型数据库:
Elasticsearch集群可以包含多个索引(indices)(数据库),每一个索引可以包含多个类型(types)(表),每一个类型包含多个文档(documents)(行),然后每个文档包含多个字段(Fields)(列)

Relational DB -> Databases -> Tables -> Rows -> Columns
Elasticsearch -> Indices   -> Types  -> Documents -> Fields

1.根据关键字查询:

http://127.0.0.1:9200/blog/hello/_search

{
"query":{
"term":{
"title":"张"
}
}
}

2.根据字符串查询

http://127.0.0.1:9200/blog/hello/_search

{
"query":{
	"query_string":{
		"default_field":"title",
		"query":"档一"
	}
}
}

IK分词器

https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v6.5.4

下载下来解压到ES的plugins的目录下,当ES启动时会自动扫描加载配置。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章