Elasticsearch概念
Elasticsearch | mysql |
---|---|
Index(索引) | 数据库 |
Type(类型) | 表 |
Documents(文档) | 行 |
Fields | 列 |
常用命令
文章来源地址https://www.toymoban.com/news/detail-723046.html
索引
# 索引初始化,number_of_shards:分片数,不可修改;number_of_replicas:副本数,可修改
PUT lagou
{
"settings": {
"index": {
"number_of_shards": 5,
"number_of_replicas": 1
}
}
}
# 获取索引settings
GET lagou/_settings
GET _all/_settings
GET _settings
GET .kibana,lagou/_settings
# 更新索引
PUT lagou/_settings
{
“number_of_replicas”:2
}
# 获取索引信息
GET _all
GET lagou
CRUD
# 新建
# 新建数据,指定id
PUT lagou/job/1
{
"title": "python分布式爬虫",
"salary_min":15000,
"city":"北京",
"company":{
"name":"百度",
"company_addr":"北京市软件园"
},
"publish_date": "2017-4-16",
"comments":15
}
# 新建数据
POST lagou/job/
{
"title": "python分布式爬虫",
"salary_min":15000,
"city":"北京",
"company":{
"name":"百度",
"company_addr":"北京市软件园"
},
"publish_date": "2017-4-16",
"comments":15
}
# 查询
GET lagou/job/1
# 只获取title字段
GET lagou/job/1?_source=title
# 获取title,city字段
GET lagou/job/1?_source=title,city
# 获取所有字段
GET lagou/job/1?_source
# 修改
# 覆盖更新
PUT lagou/job/1
{
"title":"python分布式爬虫",
"salary_min":15000,
"company":{
"name":"百度",
"company_addr":"北京市软件园"
},
"publish_date": "2017-4-16",
"comments":15
}
# 更新指定字段
POST lagou/job/1/_update
{
"doc":{
"comments":20
}
}
# 删除
# 删除文档
DELETE lagou/job/1
# 删除索引
DELETE lagou
文章来源:https://www.toymoban.com/news/detail-723046.html
到了这里,关于elasticsearch常用命令的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!