elasticsearch初步检索

GET /_cat/nodes  查看所有节点
GET /_cat/health  查看健康状况
GET /_cat/master 查看主节点
GET /_cat/indices 查看所有的索引 类似mysql中的show databases;

2、索引一个文档(保存一条记录)
PUT customer/external/1
{
"name": "tom"
}
POST 、PUT都可以,都是保存新增二合一
POST新增,可以不指定id,会自动生成一个id
PUT不允许不带ID

3、查询文档
GET customer/external/1

4、更新文档
POST | PUT /customer/external/1/_update //这种方式会对比原数据,如果没有发生变化就不更新
{
"doc":{
"name":"dffff"
}
}
或者
PUT /customer/external/1
{
"name":"dffff"
}

5、删除文档、索引
DELETE customer/external/1
DELETE customer

6、bulk批量API
POST customer/external/_bulk
{"index":{"_id":"1"}}
{"name": "John Doe"}
{"index":{"_id":"2"}}
{"name":"Jane Doe"}

语法格式:
{action: {metadata}} \n
{request body } \n

{action: {metadata}} \n
{request body} \n

复杂实例:
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"}}
{"doc": {"title": "My updated blog post"}}

你可能感兴趣的:(elasticsearch初步检索)