ElasticSearch (1) – 入门概念和文档CRUD

如果你已经有RDBMS的经验了,以下的抽象与类比会让你更容易的了解和学习ElasticSearch

RDBMSElasticSearch
TableIndex(Type)
RowDocument
ColumnFiled
SchemaMapping
SQLDSL

在ElasticSeach 7 版本开始,所有的Type名都约定用_doc

Index如果ID 1不存在就会创建新的。否则,将先删除现有的文档,然后再创建新文档,版本号会增加
PUT people/_doc/1
{
“name”:”test”,
“age”:19
}
Create在people索引当中,创建ID 1的文档
POST people/_create/1
{
“name”:”test”,
“age”:19
}

POST people/_doc (不指定ID, 自动生成)
{
“name”:”test”,
“age”:19
}
Read读取ID 1的数据
GET people/_doc/1
Update文档必须已经存在,更改原有字段做增量或更改
POST people/_update/1
{
“age”:”22″
}
Delete在people索引中,删除ID 1的文档
DELETE people/_doc/1

删除整个people索引
DELETE people

Loading

Facebook评论