Open Source, Open Future!
  menu
107 文章
ღゝ◡╹)ノ❤️

elasticsearch---索引

新增

PUT /product

以上请求会使用默认配置:

number_of_shards:主分片个数,默认是5(一旦确定,不能修改);
number_of_replicas:复制分片个数,默认是1;

也可以自定义配置,比如:

PUT /product
{
  "settings":{
    "index":{
      "number_of_shards": 3,
      "number_of_replicas": 0
    }
  }
}

查询

1、查询指定索引:

GET /product

返回结果:

{
  "product": {
    "aliases": {},
    "mappings": {},
    "settings": {
      "index": {
        "creation_date": "1559383000089",
        "number_of_shards": "5",
        "number_of_replicas": "1",
        "uuid": "F-_1Y5GDTGKzVdoMKNC0xQ",
        "version": {
          "created": "6020499"
        },
        "provided_name": "product"
      }
    }
  }
}

2、查询所有索引:

GET /_all

修改

修改复制节点的个数

PUT /product/_settings
{
    "number_of_replicas": 2
}

删除索引

1、删除指定索引:

DELETE /product

2、删除所有索引:

DELETE /_all