一起来玩Elasticsearch,加我微信:wx1250134974
Elasticsearch认证复习准备
https://www.elastic.co/guide/cn/elasticsearch/guide/current/getting-started.html
##索引文档、更新文档(id可以自定义也可以使用默认生成的)
PUT /website/blog/123
{
"title": "My first blog entry",
"text": "Just trying this out...",
"date": "2014/01/01"
}
POST /website/blog/
{
"title": "My second blog entry",
"text": "Still trying this out...",
"date": "2014/01/01"
}
##取回一个文档
GET /website/blog/123?pretty
##创建新文档而不是覆盖已有文档
PUT /website/blog/123/_create
{
"title": "My first blog entry",
"text": "Just trying this out...",
"date": "2014/01/01"
}
##删除文档
DELETE /website/blog/123
##并发控制更新
PUT /website/blog/123?version=1
{
"title": "My first blog entry",
"text": "Just trying this out...",
"date": "2014/01/01"
}
##部分更新
POST /website/blog/123/_update
{
"doc" : {
"tags" : [ "testing" ],
"views": 0,
"date": "2014/01/01"
}
}
##更新已有映射(只能增加新的域映射,不能更新现有的域映射)
PUT /website/blog/_mapping
{
"properties" : {
"tag" : {
"type" : "text",
"index": "not_analyzed"
}
}
}
##一次获取多个文档
GET /_mget
{
"docs" : [
{
"_index" : "website",
"_type" : "blog",
"_id" : 123
},
{
"_index" : "website",
"_type" : "pageviews",
"_id" : 123,
"_source": "views"
}
]
}
GET /website/blog/_mget
{
"ids" : [ "123", "1" ]
}
##批量操作
https://www.elastic.co/guide/cn/elasticsearch/guide/current/bulk.html
POST /_bulk
{ "delete": { "_index": "website", "_type": "blog", "_id": "123" }}
{ "create": { "_index": "website", "_type": "blog", "_id": "123" }}
{ "title": "My first blog post" }
{ "index": { "_index": "website", "_type": "blog" }}
{ "title": "My second blog post" }
{ "update": { "_index": "website", "_type": "blog", "_id": "123", "_retry_on_conflict" : 3} }
{ "doc" : {"title" : "My updated blog post"} }
一起来玩Elasticsearch,加我微信:wx1250134974