Elasticsearch 7.0 Cookbook(Fourth Edition)
上QQ阅读APP看书,第一时间看更新

How it works...

During index creation, the replication can be set with two parameters in the settings/index object:

  • The number_of_shards, which controls the number of shards that compose the index (every shard can store up to 232 documents)
  • The number_of_replicas, which controls the number of replications (how many times your data is replicated in the cluster for high availability)
  • A good practice is to set this value to at least 1

The API call initializes a new index, which means the following:

  • The index is created in a primary node first and then its status is propagated to all the nodes at the cluster level
  • A default mapping (empty) is created
  • All the shards required by the index are initialized and ready to accept data

The index creation API allows for the definition of mapping during creation time. The parameter that's required to define a mapping is mapping, and it accepts multiple mappings. So, in a single call, it is possible to create an index and put the required mappings.

There are also some limitations to the index name; the only accepted characters are as follows:

  • ASCII letters [a-z]
  • Numbers [0-9]
  • Point ., minus -, &, and _