创建索引

现在我们来创建一个名为“customer”的索引,然后再次列出所有的索引:

curl -XPUT 'localhost:9200/customer?pretty'
curl 'localhost:9200/_cat/indices?v'

命令的第一行使用PUT方法创建名为“customer”的索引。我们只是简单地在请求的后面添加了 pretty ,来告诉Elasticsearch 简单的打印JSON响应。

响应:

curl -XPUT 'localhost:9200/customer?pretty'
{
  "acknowledged" : true
}

curl 'localhost:9200/_cat/indices?v'
health index    pri rep docs.count docs.deleted store.size pri.store.size
yellow customer   5   1          0            0       495b           495b

第二个命令的响应告诉我们现在我们有一个索引,这个索引名为“customer”,它有五个主分片,一个副本分片,里面包含0个文档。

你可能也注意到了customer索引的健康值为黄色。回想我们之前的讨论,黄色意味着一些副本还没被分配。之所以会发生这个情况,是因为Elasticsearch 默认给这个索引创建一个副本。但是因为我们仅仅只有一个节点在运行,在另外一个节点加入集群之前,不会分配任何副本。一旦副本被分配到了第二个节点上,健康状态将会转变成绿色。

results matching ""

    No results matching ""