1.安装:
启动:
启动成功:
2.安装head插件(提供web界面,基本信息的查看,rest请求的模拟,数据基本检索):
安装:
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
安装依赖包:
npm install
启动:
npm run start
修改配置文件
这里可以配置主从
./bin/elasticsearch -d 后台启动
3.索引>类型>文档
索引创建
{
"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.自动产生文档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