ES 安装、search、index、doc
2023-02-18 16:46:00 时间
文章目录
1. 安装
- 下载 https://www.elastic.co/cn/downloads/past-releases/elasticsearch-8-5-3 https://www.elastic.co/cn/downloads/past-releases/kibana-8-5-3
- 解压,点击
D:\elasticsearch-8.5.3\bin\elasticsearch.bat
启动后会报错 - 修改配置
"D:\elasticsearch-8.5.3\config\elasticsearch.yml"
配置文件会多出来一些配置
学习环境下,全部改为false
即可
# Enable security features
xpack.security.enabled: False
xpack.security.enrollment.enabled: False
# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:
enabled: False
keystore.path: certs/http.p12
# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:
enabled: False
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
- 再重新启动 ES 在浏览器输入 http://localhost:9200/ 看见 json,就算安装好了
- 点击
"D:\kibana-8.5.3\bin\kibana.bat"
http://localhost:5601/app/dev_tools#/console - 测试
写入 doc
put product/_doc/1
{
"name": "apple",
"price": 5.6
}
返回
{
"_index": "product",
"_id": "1",
"_version": 3,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 2,
"_primary_term": 1
}
查询 doc
get /product/_doc/1
返回
{
"_index": "product",
"_id": "1",
"_version": 3,
"_seq_no": 2,
"_primary_term": 1,
"found": true,
"_source": {
"name": "apple",
"price": 5.6
}
}
2. search
查看所有 index
get _cat/indices
从 index 中 from 第几个数据开始,size 个docs
GET kibana_sample_data_logs/_search?from=1&size=2
3. index
创建 index
PUT test_index
{
"settings":{
"number_of_shards": 1,
"number_of_replicas": 1
}
}
删除 index
DELETE test_index
创建完 index 后,主分片数量、index名、字段类型
不可以再修改
重新创建文档,只会带过来 doc,属性设置不会带过来
POST _reindex
{
"source": {
"index": "test_index"
},
"dest": {
"index": "new_test_index"
}
}
检查 index 是否存在
head new_test_index
4. doc CRUD
创建发生在 主分片(可读可写) 操作类型:
- index:更新
- create:只创建,不更新,如果存在相同doc报错
PUT test_index/_doc/1?op_type=create
{
"name": "test1"
}
id 1 的 doc 已存在,create 报错
{
"error": {
"root_cause": [
{
"type": "version_conflict_engine_exception",
"reason": "[1]: version conflict, document already exists (current version [1])",
"index_uuid": "ntM1X5SOTxiz8tRVwdHK6g",
"shard": "0",
"index": "test_index"
}
],
"type": "version_conflict_engine_exception",
"reason": "[1]: version conflict, document already exists (current version [1])",
"index_uuid": "ntM1X5SOTxiz8tRVwdHK6g",
"shard": "0",
"index": "test_index"
},
"status": 409
}
index 操作,替换 doc
PUT test_index/_doc/1?op_type=index
{
"name": "test_new"
}
{
"_index": "test_index",
"_id": "1",
"_version": 2,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 1,
"_primary_term": 1
}
POST 可以自动生成 随机 id
POST test_index/_doc/
{
"name": "test_new"
}
{
"_index": "test_index",
"_id": "YrdpU4UBIo5EnYllVY0M",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 4,
"_primary_term": 1
}
相关文章
- 智慧井盖,守护脚下安全!
- 看守所视频AI行为分析系统 YOLOv5
- 后疫情时代的公司进化论:从效率为先到稳健取胜
- 第十五篇:ReactDOM.render 是如何串联渲染链路的?(下)
- ohmyz 主题
- homebrew 的 tap 功能详解
- 客快物流大数据项目(七十五):使用impala创建kudu表
- ohmyz 插件
- VSCode 插件 Remote SSH 连接远程服务器
- 港交所上市虚拟资产ETF,审慎发展虚拟资产迈出关键步伐
- 客快物流大数据项目(七十六):使用Impala对kudu进行DML操作
- 解绑开发者、修改管理员
- 客快物流大数据项目(七十七):使用Impala对kudu更改表属性操作
- 客快物流大数据项目(七十八):Hue简介
- 客快物流大数据项目(七十九):Impala映射kudu表
- 客快物流大数据项目(八十):用户标签开发
- 搜狗浏览器账号密码解密
- 鼠标教鞭:Presentify for mac
- 内存取证工具Volatility学习
- 如何隐藏你的真实ip