Class IndexMetaData

    • Method Detail

      • getIndex

        public Index getIndex()
      • getIndexUUID

        public String getIndexUUID()
      • isSameUUID

        public boolean isSameUUID​(String otherUUID)
        Test whether the current index UUID is the same as the given one. Returns true if either are _na_
      • getVersion

        public long getVersion()
      • getMappingVersion

        public long getMappingVersion()
      • getSettingsVersion

        public long getSettingsVersion()
      • getAliasesVersion

        public long getAliasesVersion()
      • getCreationVersion

        public Version getCreationVersion()
        Return the Version on which this index has been created. This information is typically useful for backward compatibility.
      • getUpgradedVersion

        public Version getUpgradedVersion()
        Return the Version on which this index has been upgraded. This information is typically useful for backward compatibility.
      • getCreationDate

        public long getCreationDate()
      • getNumberOfShards

        public int getNumberOfShards()
      • getNumberOfReplicas

        public int getNumberOfReplicas()
      • getRoutingPartitionSize

        public int getRoutingPartitionSize()
      • isRoutingPartitionedIndex

        public boolean isRoutingPartitionedIndex()
      • getTotalNumberOfShards

        public int getTotalNumberOfShards()
      • getSettings

        public Settings getSettings()
      • getMappings

        @Deprecated
        public ImmutableOpenMap<String,​MappingMetaData> getMappings()
        Deprecated.
        Use mapping() instead now that indices have a single type
        Return an object that maps each type to the associated mappings. The return value is never null but may be empty if the index has no mappings.
      • mapping

        @Nullable
        public MappingMetaData mapping()
        Return the concrete mapping for this index or null if this index has no mappings at all.
      • defaultMapping

        @Nullable
        public MappingMetaData defaultMapping()
        Get the default mapping. NOTE: this is always null for 7.x indices which are disallowed to have a default mapping.
      • getResizeSourceIndex

        public Index getResizeSourceIndex()
      • mappingOrDefault

        @Nullable
        public MappingMetaData mappingOrDefault()
        Sometimes, the default mapping exists and an actual mapping is not created yet (introduced), in this case, we want to return the default mapping in case it has some default mapping definitions.

        Note, once the mapping type is introduced, the default mapping is applied on the actual typed MappingMetaData, setting its routing, timestamp, and so on if needed.

      • inSyncAllocationIds

        public Set<String> inSyncAllocationIds​(int shardId)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • addHumanReadableSettings

        public static Settings addHumanReadableSettings​(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
      • getRoutingFactor

        public int getRoutingFactor()
        Returns the routing factor for this index. The default is 1.
        See Also:
        for details
      • selectSplitShard

        public static ShardId selectSplitShard​(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 static ShardId selectCloneShard​(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 static Set<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 static Set<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 static int getRoutingFactor​(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.