Interface Document
- All Superinterfaces:
Map<String,,Object> StringObjectMap<Document>
- All Known Subinterfaces:
SearchDocument
- All Known Implementing Classes:
SearchDocumentAdapter
Map. All iterators preserve
original insertion order.
Document does not allow null keys. It allows null values.
Implementing classes can be either mutable or immutable. In case a subclass is immutable, its methods may throw
UnsupportedOperationException when calling modifying methods.
- Since:
- 4.0
- Author:
- Mark Paluch, Peter-Josef Meisch, Roman Puchkovskiy
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Documentcreate()Create a new mutableDocument.static Documentdefault Documentinitializes this object from the given JSON String.default StringgetId()Retrieve the identifier associated with thisDocument.default StringgetIndex()default longRetrieve the primary_term associated with thisDocument.default longgetSeqNo()Retrieve the seq_no associated with thisDocument.default longRetrieve the version associated with thisDocument.default booleanhasId()Return true if thisDocumentis associated with an identifier.default booleanReturn true if thisDocumentis associated with a primary_term.default booleanhasSeqNo()Return true if thisDocumentis associated with a seq_no.default booleanReturn true if thisDocumentis associated with a version.static DocumentParse JSON toDocument.default voidSet the identifier for thisDocument.default voidSets the index name for this documentdefault voidsetPrimaryTerm(long primaryTerm) Set the primary_term for thisDocument.default voidsetSeqNo(long seqNo) Set the seq_no for thisDocument.default voidsetVersion(long version) Set the version for thisDocument.default <R> RThis method allows the application of a function tothisDocument.Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from interface org.springframework.data.elasticsearch.support.StringObjectMap
append, get, getBoolean, getBooleanOrDefault, getBooleanOrDefault, getInt, getIntOrDefault, getIntOrDefault, getLong, getLongOrDefault, getLongOrDefault, getString, getStringOrDefault, getStringOrDefault, toJson
-
Method Details
-
create
Create a new mutableDocument.- Returns:
- a new
Document.
-
from
- Parameters:
map- source map containing key-value pairs and sub-documents. must not be null.- Returns:
- a new
Document.
-
parse
Parse JSON toDocument.- Parameters:
json- must not be null.- Returns:
- the parsed
Document.
-
fromJson
Description copied from interface:StringObjectMapinitializes this object from the given JSON String.- Specified by:
fromJsonin interfaceStringObjectMap<Document>- Parameters:
json- must not be null
-
hasId
default boolean hasId()Return true if thisDocumentis associated with an identifier.- Returns:
- true if this
Documentis associated with an identifier, false otherwise.
-
getIndex
- Returns:
- the index if this document was retrieved from an index or was just stored.
- Since:
- 4.1
-
setIndex
Sets the index name for this document- Parameters:
index- index nameThe default implementation throws
UnsupportedOperationException.- Since:
- 4.1
-
getId
Retrieve the identifier associated with thisDocument.The default implementation throws
UnsupportedOperationException. It's recommended to checkhasId()prior to calling this method.- Returns:
- the identifier associated with this
Document. - Throws:
IllegalStateException- if the underlying implementation supports Id's but no Id was yet associated with the document.
-
setId
Set the identifier for thisDocument.The default implementation throws
UnsupportedOperationException. -
hasVersion
default boolean hasVersion()Return true if thisDocumentis associated with a version.- Returns:
- true if this
Documentis associated with a version, false otherwise.
-
getVersion
default long getVersion()Retrieve the version associated with thisDocument.The default implementation throws
UnsupportedOperationException. It's recommended to checkhasVersion()prior to calling this method.- Returns:
- the version associated with this
Document. - Throws:
IllegalStateException- if the underlying implementation supports Id's but no Id was yet associated with the document.
-
setVersion
default void setVersion(long version) Set the version for thisDocument.The default implementation throws
UnsupportedOperationException. -
hasSeqNo
default boolean hasSeqNo()Return true if thisDocumentis associated with a seq_no.- Returns:
- true if this
Documentis associated with a seq_no, false otherwise.
-
getSeqNo
default long getSeqNo()Retrieve the seq_no associated with thisDocument.The default implementation throws
UnsupportedOperationException. It's recommended to checkhasSeqNo()prior to calling this method.- Returns:
- the seq_no associated with this
Document. - Throws:
IllegalStateException- if the underlying implementation supports seq_no's but no seq_no was yet associated with the document.
-
setSeqNo
default void setSeqNo(long seqNo) Set the seq_no for thisDocument.The default implementation throws
UnsupportedOperationException. -
hasPrimaryTerm
default boolean hasPrimaryTerm()Return true if thisDocumentis associated with a primary_term.- Returns:
- true if this
Documentis associated with a primary_term, false otherwise.
-
getPrimaryTerm
default long getPrimaryTerm()Retrieve the primary_term associated with thisDocument.The default implementation throws
UnsupportedOperationException. It's recommended to checkhasPrimaryTerm()prior to calling this method.- Returns:
- the primary_term associated with this
Document. - Throws:
IllegalStateException- if the underlying implementation supports primary_term's but no primary_term was yet associated with the document.
-
setPrimaryTerm
default void setPrimaryTerm(long primaryTerm) Set the primary_term for thisDocument.The default implementation throws
UnsupportedOperationException. -
transform
This method allows the application of a function tothisDocument. The function should expect a singleDocumentargument and produce anRresult.Any exception thrown by the function will be propagated to the caller.
- Type Parameters:
R- class of the result- Parameters:
transformer- functional interface to a apply. must not be null.- Returns:
- the result of applying the function to this string
- See Also:
-