1.安裝:

屏幕快照 2017-09-17 下午4.03.27.png
啟動(dòng):

屏幕快照 2017-09-17 下午4.06.28.png
啟動(dòng)成功:

屏幕快照 2017-09-17 下午4.09.29.png

屏幕快照 2017-09-17 下午4.08.46.png
2.安裝head插件(提供web界面,基本信息的查看,rest請(qǐng)求的模擬,數(shù)據(jù)基本檢索):
安裝:
wget https://github.com/mobz/elasticsearch-head/archive/master.zip

屏幕快照 2017-09-17 下午4.17.35.png
安裝依賴包:
npm install
啟動(dòng):
npm run start
修改配置文件

屏幕快照 2017-09-17 下午6.02.42.png
這里可以配置主從
./bin/elasticsearch -d 后臺(tái)啟動(dòng)
3.索引>類型>文檔
索引創(chuàng)建
{
"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"
}
}
},
"woman": {}
}
}
插入
1.指定文檔id插入 put
2.自動(dòng)產(chǎn)生文檔id插入 post
修改
1.直接修改文檔
2.腳本修改文檔
post
127.0.0.1:9200/people/man/1/_update
{
"doc":{
"name":"大黑"
}
}
post
127.0.0.1:9200/people/man/1/_update
{
"script":{
"lang":"painless",
"inline":"ctx._source.age += 1"
}
}
{
"script":{
"lang": "painless",
"inline": "ctx._source.age = params.age",
"params": {
"age":100
}
}
}
刪除
1.刪除文檔
delete 127.0.0.1:9200/people/man/1
2.刪除索引
delete 127.0.0.1:9200/people