Package org.opensearch.core.index
Class Index
java.lang.Object
org.opensearch.core.index.Index
- All Implemented Interfaces:
Writeable,ToXContent,ToXContentObject
A value class representing the basic required properties of an OpenSearch index.
(This class is immutable.)
- Opensearch.api:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.WriteableRegistry, Writeable.Writer<V> -
Field Summary
FieldsFields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Index instance with name and unique identifierIndex(StreamInput in) Creates a new Index instance from aStreamInput. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if this index is the same as another index by comparing the name and unique identifier.static IndexfromXContent(XContentParser parser) getName()Gets the name of the index.getUUID()Gets the unique identifier of the index.inthashCode()toString()Returns either the name and unique identifier of the index or only the name if the uuid isStrings.UNKNOWN_UUID_VALUE.toXContent(XContentBuilder builder, ToXContent.Params params) voidwriteTo(StreamOutput out) Writes the name and unique identifier to theStreamOutputMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.opensearch.core.xcontent.ToXContentObject
isFragment
-
Field Details
-
EMPTY_ARRAY
-
UNKNOWN_INDEX_NAME
- See Also:
-
-
Constructor Details
-
Index
Creates a new Index instance with name and unique identifier- Parameters:
name- the name of the indexuuid- the unique identifier of the index- Throws:
NullPointerException- if either name or uuid are null
-
Index
Creates a new Index instance from aStreamInput. Reads the name and unique identifier from the stream.- Parameters:
in- the stream to read from- Throws:
IOException- if an error occurs while reading from the stream- See Also:
-
-
Method Details
-
getName
Gets the name of the index.- Returns:
- the name of the index.
-
getUUID
Gets the unique identifier of the index.- Returns:
- the unique identifier of the index. "_na_" if
Strings.UNKNOWN_UUID_VALUE.
-
toString
Returns either the name and unique identifier of the index or only the name if the uuid isStrings.UNKNOWN_UUID_VALUE.If we have a uuid we put it in the toString so it'll show up in logs which is useful as more and more things use the uuid rather than the name as the lookup key for the index.
-
equals
Checks if this index is the same as another index by comparing the name and unique identifier. If both uuid areStrings.UNKNOWN_UUID_VALUEthen only the name is compared. -
hashCode
public int hashCode() -
writeTo
Writes the name and unique identifier to theStreamOutput- Specified by:
writeToin interfaceWriteable- Parameters:
out- The stream to write to- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
fromXContent
- Throws:
IOException
-