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 Document
create()
Create a new mutableDocument
.static Document
default Document
initializes this object from the given JSON String.default String
getId()
Retrieve the identifier associated with thisDocument
.default String
getIndex()
default long
Retrieve the primary_term associated with thisDocument
.default long
getSeqNo()
Retrieve the seq_no associated with thisDocument
.default long
Retrieve the version associated with thisDocument
.default boolean
hasId()
Return true if thisDocument
is associated with an identifier.default boolean
Return true if thisDocument
is associated with a primary_term.default boolean
hasSeqNo()
Return true if thisDocument
is associated with a seq_no.default boolean
Return true if thisDocument
is associated with a version.static Document
Parse JSON toDocument
.default void
Set the identifier for thisDocument
.default void
Sets the index name for this documentdefault void
setPrimaryTerm
(long primaryTerm) Set the primary_term for thisDocument
.default void
setSeqNo
(long seqNo) Set the seq_no for thisDocument
.default void
setVersion
(long version) Set the version for thisDocument
.default <R> R
This method allows the application of a function tothis
Document
.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, values
Methods 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:StringObjectMap
initializes this object from the given JSON String.- Specified by:
fromJson
in interfaceStringObjectMap<Document>
- Parameters:
json
- must not be null
-
hasId
default boolean hasId()Return true if thisDocument
is associated with an identifier.- Returns:
- true if this
Document
is 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 thisDocument
is associated with a version.- Returns:
- true if this
Document
is 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 thisDocument
is associated with a seq_no.- Returns:
- true if this
Document
is 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 thisDocument
is associated with a primary_term.- Returns:
- true if this
Document
is 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 tothis
Document
. The function should expect a singleDocument
argument and produce anR
result.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:
-