- Are your shards increasing by 10 every time you attempt to insert a new document?
- Are you sure you are inserting the document into the index that you have created prior to attempting to insert a document? T
he reason I ask if the shards are increasing by 10 when you try to insert a document is as, then you would be instead of inserting into the index you created already you would be creating a whole new index based on ElasticSearch' out of the box defaults. Which is 5 Shards and 1 Replica, meaning 10 shards (1 set of replica to replicate the primary shards).
For example, here is how you can create an index and be in total control over how many shards are created -
curl -XPUT <host>:<port>/<index> -d '{
"settings": {
"number_of_shards": 2,
"number_of_replicas": 0,
"analysis": {
"analyzer": {
..........
..........
..........
..........
..........
..........
..........
..........
},
"filter": {
..........
..........
..........
..........
..........
..........
..........
..........
}
}
}
}'
- A shard in ElasticSearch is essentially a Lucene instance.
- A cluster in ElasticSearch is essentially one or more nodes which contain the same cluster name, allowing them to join together to spread shards in a distributed nature.
- Number of data nodes is essentially the number of nodes which aren't just coordinator nodes, i.e. nodes which will receive search requests, potentially be a master node and nodes which will hold and contain data (shards). Coordinator nodes will only distribute requests to the data nodes.
- Active primary shards are those which are happily available on a node within a cluster and active shards will include replicas in that count.
- Relocating shards are those which may be migrating to a different node within the same cluster, this is due to a new node joining the cluster and as ElasticSearch is distributed it will shift the shards to rebalance the cluster, ensuring availability.
- Shards which are not assigned to a node.