Elasticsearch核心概念VS数据库核心概念
Elasticsearch 数据库
Document 行
Type 表
Index 库
filed 字段
创建索引(相当于MySQL创建数据库)
curl -XPUT ‘192.168.2.41:9200/vipinfo?pretty’
插入文档数据
curl -XPUT ‘192.168.2.41:9200/vipinfo/user/1?pretty’ -H ‘Content-Type: application/json’ -d’
{
“first_name” : “John”,
“last_name”: “Smith”,
“age” : 25,
“about” : “I love to go rock climbing”, “interests”: [ “sports”, “music” ]
}
’
更新数据的两种方式
PUT更新,需要填写完整的信息
curl -XPUT ‘localhost:9200/vipinfo/user/1?pretty’ -H ‘Content-Type: application/json’ -d’
{
“first_name” : “John”,
“last_name”: “Smith”,
“age” : 27,
“about” : “I love to go rock climbing”, “interests”: [ “sports”, “music” ]
}
’
POST更新,只需要填写需要更改的信息?
curl -XPOST ‘localhost:9200/vipinfo/user/1?pretty’ -H ‘Content-Type: application/json’ -d’
{
“age” : 29
}
’
删除指定文档数据
curl -XDELETE 'localhost:9200/vipinfo/user/1?pretty’
删除索引
curl -XDELETE ‘localhost:9200/vipinfo?pretty’