Elasticsearch——Rest接口

一、集群接口
1、健康状态

curl -X GET "http://localhost:9200/_cat/health?v"

2、集群node

curl -X GET "http://localhost:9200/_cat/nodes?v"

3、索引列表

curl -X GET "http://localhost:9200/_cat/indices?v"

二、索引
1、创建索引

//curl -X PUT "localhost:9200/[索引名]?pretty"
curl -X PUT "http://localhost:9200/test-customer?pretty"

2、创建索引,配置mappings

curl -XPUT 'http://localhost:9200/test-customer' -H 'Content-Type: application/json' -d'
{
    "settings" : {
        "index.number_of_shards" : 3
    },
    "mappings" : {
        "_doc" : { //_doc 为index的type
            "properties" : {
                 "name": {"type": "keyword"}, 
                 "title": {"type": "text", "index": "true"},
                 "price": {
                    "type": "scaled_float",  
                    "scaling_factor": 100
                }
            }
        }
    }
}'

3、删除索引

curl -X DELETE "http://localhost:9200/test-customer?pretty"

4、添加文档
PUT协议,Json格式文档,_doc 为index的type

curl -X PUT "http://localhost:9200/test-customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
  "name": "John Doe"
}'

5、通过id查询文档记录

curl -X GET "http://localhost:9200/test-customer/_doc/1?pretty"

6、更新文档

curl -X POST "http://localhost:9200/test-customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'{
  "name":"John Doe",
  "title":"防螨虫床上用品四件套",
  "price":"65.00",
  "firename":"1111aaaa",
  "uuid":"1111111"
}'

7、删除文档

curl -X DELETE "http://localhost:9200/test-customer/_doc/1?pretty"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值