其他分享
首页 > 其他分享> > elasticsearch

elasticsearch

作者:互联网

 

索引文档

PUT /{index}/{type}/{id}
{
  "field": "value",
  ...
}

例如:
PUT /website/blog/123
{
  "title": "My first blog entry",
  "text":  "Just trying this out...",
  "date":  "2014/01/01"
}

 

取回一个文档

GET /website/blog/123?pretty

返回文档一部分

GET /website/blog/123?_source=title,text

文档检查是否存在(用HEAD请求)

curl -i -XHEAD http://localhost:9200/website/blog/123

 

更新整个文档

在 Elasticsearch 中文档是 不可改变 的,不能修改它们。相反,如果想要更新现有的文档,需要 重建索引 或者进行替换

PUT /website/blog/123
{
  "title": "My first blog entry",
  "text":  "I am starting to get the hang of this...",
  "date":  "2014/01/02"
}

创建文档

第一种
PUT /website/blog/123?op_type=create
{ ... }

第二种
PUT /website/blog/123/_create
{ ... }

删除文档

DELETE /website/blog/123

 

指定版本更新索引

PUT /website/blog/1?version=1 
{
  "title": "My first blog entry",
  "text":  "Starting to get the hang of this..."
}

文档部分更新

POST /website/blog/1/_update
{
   "doc" : {
      "tags" : [ "testing" ],
      "views": 0
   }
}

取回多个文档

GET /_mget
{
   "docs" : [
      {
         "_index" : "website",
         "_type" :  "blog",
         "_id" :    2
      },
      {
         "_index" : "website",
         "_type" :  "pageviews",
         "_id" :    1,
         "_source": "views"
      }
   ]
}

 

标签:website,...,blog,123,文档,PUT,elasticsearch
来源: https://www.cnblogs.com/zhoufly-blog/p/16342201.html