These internal settings are no longer added to new indices. They are deprecated but still defined
to retain compatibility with old indexes. TODO: remove in 9.0.
public static finalStringSETTING_INDEX_PROVIDED_NAME
The user provided name for an index. This is the plain string provided by the user when the index was created.
It might still contain date math expressions etc. (added in 5.0)
public staticSettingsaddHumanReadableSettings(Settings settings)
Adds human readable version and creation date settings.
This method is used to display the settings in a human readable format in REST API
getRoutingNumShards
publicintgetRoutingNumShards()
Returns the number of shards that should be used for routing. This basically defines the hash space we use in
OperationRouting.generateShardId(IndexMetadata, String, String) to route documents
to shards based on their ID or their specific routing value. The default value is getNumberOfShards(). This value only
changes if and index is shrunk.
getRoutingFactor
publicintgetRoutingFactor()
Returns the routing factor for this index. The default is 1.
public staticShardIdselectSplitShard(int shardId,
IndexMetadata sourceIndexMetadata,
int numTargetShards)
Returns the source shard ID to split the given target shard off
Parameters:
shardId - the id of the target shard to split into
sourceIndexMetadata - the source index metadata
numTargetShards - the total number of shards in the target index
Returns:
a the source shard ID to split off from
selectCloneShard
public staticShardIdselectCloneShard(int shardId,
IndexMetadata sourceIndexMetadata,
int numTargetShards)
Returns the source shard ID to clone the given target shard off
Parameters:
shardId - the id of the target shard to clone into
sourceIndexMetadata - the source index metadata
numTargetShards - the total number of shards in the target index
Returns:
a the source shard ID to clone from
selectRecoverFromShards
public staticSet<ShardId>selectRecoverFromShards(int shardId,
IndexMetadata sourceIndexMetadata,
int numTargetShards)
Selects the source shards for a local shard recovery. This might either be a split or a shrink operation.
Parameters:
shardId - the target shard ID to select the source shards for
sourceIndexMetadata - the source metadata
numTargetShards - the number of target shards
selectShrinkShards
public staticSet<ShardId>selectShrinkShards(int shardId,
IndexMetadata sourceIndexMetadata,
int numTargetShards)
Returns the source shard ids to shrink into the given shard id.
Parameters:
shardId - the id of the target shard to shrink to
sourceIndexMetadata - the source index metadata
numTargetShards - the total number of shards in the target index
Returns:
a set of shard IDs to shrink into the given shard ID.
getRoutingFactor
public staticintgetRoutingFactor(int sourceNumberOfShards,
int targetNumberOfShards)
Returns the routing factor for and shrunk index with the given number of target shards.
This factor is used in the hash function in
OperationRouting.generateShardId(IndexMetadata, String, String) to guarantee consistent
hashing / routing of documents even if the number of shards changed (ie. a shrunk index).
Parameters:
sourceNumberOfShards - the total number of shards in the source index
targetNumberOfShards - the total number of shards in the target index
Returns:
the routing factor for and shrunk index with the given number of target shards.
Throws:
IllegalArgumentException - if the number of source shards is less than the number of target shards or if the source shards
are not divisible by the number of target shards.
parseIndexNameCounter
public staticintparseIndexNameCounter(String indexName)
Parses the number from the rolled over index name. It also supports the date-math format (ie. index name is wrapped in < and >)
E.g.
- For ".ds-logs-000002" it will return 2
- For "<logs-{now/d}-3>" it'll return 3
Throws:
IllegalArgumentException - if the index doesn't contain a "-" separator or if the last token after the separator is not a
number