A. Head download and install plug-ins
1.head plugin download
Download and install the plug head is more intuitive to see the changes in the data, and can achieve a simple operation on the data. elasticsearch5.0 following versions can be performed directly in the directory corresponding to the command to install elasticsearch head plug, but less than 5.0 does not support direct mounting, mounting step 5.6.9 above this introduction of the plug head.
Download: https://github.com/mobz/elasticsearch-head
You can unzip to any directory, but separate from the installation directory of the District elasticsearch! ! !
2.node.js download and install it yourself
Because the head is a Node.js project. So, if there is no need to install nodejs installed Node.js, to Node.js v4.4.3 LTS (Long Term Support) version, for example.
- 32 Download installation package: https://nodejs.org/dist/v4.4.3/node-v4.4.3-x86.msi
- 64 Download installation package: https://nodejs.org/dist/v4.4.3/node-v4.4.3-x64.msi
Detect environment variable is configured in Node.js, open a command line, type the command "path" after to see:
Enter the command "node --version" to view node version:
3. Install grunt
Because running head needs the grunt command, so you need to install grunt. Node.js into the directory, execute the command npm install -g grunt-cli, install the grunt-bit global commands.
Head into the home directory to perform the installation npm install grunt, grunt -version executed after the installation is complete to see if the installation is successful, it will display the version number installed.
4. Head Configuration
1) Access config installation directory under the directory, the file elasticsearch.yml modify, add the following code to the end of file
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
2) network.host: 192.168.0.1 and Notes to network.host: 0.0.0.0; remove cluster.name node.name http.port, annotations (i.e. # removed)
. 3) Double elasticsearch.bat restart ES
. 4 .) to find the folder head downloaded file Gruntfile.js, together with the corresponding position in the hostname: '*'
5) head starts:. enter the command execution head npm the install folder after installation or execution grunt server npm run start running head plug, if unsuccessful re-install grunt. Success follows:
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
6) under the browser to http:. // localhost: 9100 /
Import data exemplary 5.postman
1) Create an index and mapping
--put请求 localhost:9200/local_library索引名
mappings:
{
"mappings":{
"book":{
"properties":{
"book_id":{
"type":"long",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_code":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_name":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_price":{
"type":"integer",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_author":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_desc":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
}
}
}
If you want to try a new postman data, you can add the following code
-- post请求 localhost:9200/local_library/book/1 索引/对象/id
{
"Book_id":. 1,
"book_code": "A0001",
"BOOK_NAME": "Emperor Qin",
"book_price": 180 [,
"BOOK_AUTHOR": "Tang three little",
"book_desc": "best looking fantasy novel ! "
}
The results can be viewed in the head tag data view, may be viewed by the code postman operates as follows:
-- post请求 localhost:9200/local_library/_search?pretty
{
"query": {
"match": {
"id": "1"
}
}
}
</div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-b6c3c6d139.css" rel="stylesheet">
<div class="more-toolbox">
<div class="left-toolbox">
<ul class="toolbox-list">
<li class="tool-item tool-active is-like "><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#csdnc-thumbsup"></use>
</svg><span class="name">点赞</span>
<span class="count"></span>
</a></li>
<li class="tool-item tool-active is-collection "><a href="javascript:;" data-report-click="{"mod":"popu_824"}"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-Collection-G"></use>
</svg><span class="name">收藏</span></a></li>
<li class="tool-item tool-active is-share"><a href="javascript:;"><svg class="icon" aria-hidden="true">
<use xlink:href="#icon-csdnc-fenxiang"></use>
</svg>分享</a></li>
<!--打赏开始-->
<!--打赏结束-->
<li class="tool-item tool-more">
<a>
<svg t="1575545411852" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5717" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M179.176 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5718"></path><path d="M509.684 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5719"></path><path d="M846.175 499.222m-113.245 0a113.245 113.245 0 1 0 226.49 0 113.245 113.245 0 1 0-226.49 0Z" p-id="5720"></path></svg>
</a>
<ul class="more-box">
<li class="item"><a class="article-report">文章举报</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="person-messagebox">
<div class="left-message"><a href="https://blog.csdn.net/weixin_44008460">
<img src="https://profile.csdnimg.cn/5/6/2/3_weixin_44008460" class="avatar_pic" username="weixin_44008460">
<img src="https://g.csdnimg.cn/static/user-reg-year/2x/1.png" class="user-years">
</a></div>
<div class="middle-message">
<div class="title"><span class="tit"><a href="https://blog.csdn.net/weixin_44008460" data-report-click="{"mod":"popu_379"}" target="_blank">Make it!</a></span>
</div>
<div class="text"><span>发布了25 篇原创文章</span> · <span>获赞 6</span> · <span>访问量 2000</span></div>
</div>
<div class="right-message">
<a href="https://im.csdn.net/im/main.html?userName=weixin_44008460" target="_blank" class="btn btn-sm btn-red-hollow bt-button personal-letter">私信
</a>
<a class="btn btn-sm bt-button personal-watch" data-report-click="{"mod":"popu_379"}">关注</a>
</div>
</div>
</div>
一. head插件下载及安装
1.head插件下载
下载安装head插件是为了更直观的看到数据的变化,并可以实现对数据的简单操作。elasticsearch5.0以下版本可以直接在elasticsearch目录下执行对应的命令安装head插件,但是5.0以上不支持直接安装,本篇介绍5.6.9以上head插件的安装步骤。
下载地址:https://github.com/mobz/elasticsearch-head
可解压到任意目录,但要与elasticsearch的安装目录区分开!!!
2.node.js下载并自行安装
因为head是一个Node.js项目。所以,如果没有安装nodejs需要先安装Node.js,以 Node.js v4.4.3 LTS(长期支持版本)版本为例。
- 32位安装包下载地址: https://nodejs.org/dist/v4.4.3/node-v4.4.3-x86.msi
- 64位安装包下载地址: https://nodejs.org/dist/v4.4.3/node-v4.4.3-x64.msi
检测环境变量中是否配置了Node.js,打开命令行输入命令"path"后可查看:
输入命令"node --version"可查看node版本:
3.安装grunt
Because running head needs the grunt command, so you need to install grunt. Node.js into the directory, execute the command npm install -g grunt-cli, install the grunt-bit global commands.
Head into the home directory to perform the installation npm install grunt, grunt -version executed after the installation is complete to see if the installation is successful, it will display the version number installed.
4. Head Configuration
1) Access config installation directory under the directory, the file elasticsearch.yml modify, add the following code to the end of file
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
2) network.host: 192.168.0.1 and Notes to network.host: 0.0.0.0; remove cluster.name node.name http.port, annotations (i.e. # removed)
. 3) Double elasticsearch.bat restart ES
. 4 .) to find the folder head downloaded file Gruntfile.js, together with the corresponding position in the hostname: '*'
5) head starts:. enter the command execution head npm the install folder after installation or execution grunt server npm run start running head plug, if unsuccessful re-install grunt. Success follows:
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
6) under the browser to http:. // localhost: 9100 /
Import data exemplary 5.postman
1) Create an index and mapping
--put请求 localhost:9200/local_library索引名
mappings:
{
"mappings":{
"book":{
"properties":{
"book_id":{
"type":"long",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_code":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_name":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_price":{
"type":"integer",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_author":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
},
"book_desc":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword",
"ignore_above":256
}
}
}
}
}
}
}
If you want to try a new postman data, you can add the following code
-- post请求 localhost:9200/local_library/book/1 索引/对象/id