ES 创建索引

1 : 查看 es 的一些基本状态

  • 检查Elasticsearch是否正在运行 : curl http://localhost:9200/
  • 集群健康 : GET “localhost:9200/_cat/health?v”
  • 查看全部索引 : GET “localhost:9200/_cat/indices?v”

2 : 创建索引

例如创建索引名称 roc_test_index , 索引 type : roc_test_type

1 : 我一般是直接新增一条数据,ID 是1 :

PUT /roc_test_index/roc_test_type/1
{
	"id":"1"
}

返回结果 :

{
  "_index": "roc_test_index",
  "_type": "roc_test_type",
  "_id": "1",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 2,
    "successful": 2,
    "failed": 0
  },
  "_seq_no": 0,
  "_primary_term": 1
}

这样的话一个简单的索引就创建好了 ,同时 mapping 也好了

2 : 查看一下新增的索引 :

GET /roc_test_index/roc_test_type/_search
{
	"query":{
    "match_all":{}
  }
}

返回结果 :

{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1.0,
    "hits": [
      {
        "_index": "roc_test_index",
        "_type": "roc_test_type",
        "_id": "1",
        "_score": 1.0,
        "_source": {
          "id": "1"
        }
      }
    ]
  }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值