elasticsearch支持restapi可以直接通过postman访问:
1、_cat:
| url | method | explain | 
| http://ip:port/_cat/nodes | get | 查看节点信息 | 
| http://ip:port/_cat/health | get | 查看健康情况 | 
| http://ip:port/_cat/master | get | 查看主节点信息 | 
| http://ip:port/_cat/indices | get | 查看所有索引,类似于数据库的show databases; | 
2、如何保存一个文档(保存在哪个索引的哪个类型下,就类似于保存数据库的哪个库的哪张表下面)
| url | method | distribute | 
| http://ip:port/index/type/key | put | index是索引名,类似于数据库;type是类型名,类似于数据表;key是数据的唯一值;参数是json数据。多次请求就是更新操作 | 
| http://ip:port/index/type/key | post | 和put类似只不过是可以不带id保存,每次保存自动生成id。 | 
3、如何查询一个文档
| url | method | distribute | 
| http://ip:port/index/type/key | get | 返回数据 | 
| 模拟乐观锁 | ||
| http://ip:port/index/type/key?if_seq_no=2&if_primary_term=1 | put | 
4、更新文档
| url | method | distribute | 
| http://ip:port/index/type/key/_update | post | 会对比原数据,如果数据相同就不会再进行任何操作。参数:{"doc":{data}}必须是doc的对象 | 
| http://ip:port/index/type/key/ | post/put | 不会检查原数据,一直是更新操作,参数就是更新对象的json。 | 
5、删除文档&索引
| url | method | distribute | 
| http://ip:port/index/type/key/ | delete | 删除文档 | 
| http://ip:port/index | delete | 删除索引 | 
6、bulk批量api
需要使用kibana操作:
| url | method | distribute | 
| /index/type/key/ | POST | 参数格式: {"index":{"_id":"1"}} 第一个json对象是操作类型,第二个json对象是新增数据 | 
elasticsearch官方提供的操作数据:链接:https://pan.baidu.com/s/1VFH48rP3UhJfJemFEZNmcw 提取码:ibvj
  
 
                   
                   
                   
                   
                             本文档详细介绍了如何使用Elasticsearch的REST API进行各种操作,包括查看节点信息、健康状态、主节点信息和索引,以及保存、查询、更新和删除文档。此外,还提到了批量操作API,并提供了示例链接。通过Postman等工具,可以方便地与Elasticsearch交互。
本文档详细介绍了如何使用Elasticsearch的REST API进行各种操作,包括查看节点信息、健康状态、主节点信息和索引,以及保存、查询、更新和删除文档。此外,还提到了批量操作API,并提供了示例链接。通过Postman等工具,可以方便地与Elasticsearch交互。
           
       
           
                 
                 
                 
                 
                 
                
               
                 
                 
                 
                 
                
               
                 
                 扫一扫
扫一扫
                     
              
             
                  
 被折叠的  条评论
		 为什么被折叠?
被折叠的  条评论
		 为什么被折叠?
		 
		  到【灌水乐园】发言
到【灌水乐园】发言                                
		 
		 
    
   
    
   
             
            


 
            