Class SearchDocumentAdapter
- All Implemented Interfaces:
Map<String,
,Object> Document
,SearchDocument
,StringObjectMap<Document>
SearchDocument
implementation using a Document
delegate.- Since:
- 4.4
- Author:
- Mark Paluch, Peter-Josef Meisch
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionSearchDocumentAdapter
(Document delegate, float score, Object[] sortValues, Map<String, List<Object>> fields, Map<String, List<String>> highlightFields, Map<String, SearchDocumentResponse> innerHits, NestedMetaData nestedMetaData, Explanation explanation, List<String> matchedQueries, String routing) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
void
forEach
(BiConsumer<? super String, ? super Object> action) <T> T
Returns the value to which the specifiedkey
is mapped, or null if this document contains no mapping for the key.getId()
Retrieve the identifier associated with thisDocument
.getIndex()
long
Retrieve the primary_term associated with thisDocument
.float
getScore()
Return the searchscore
.long
getSeqNo()
Retrieve the seq_no associated with thisDocument
.Object[]
long
Retrieve the version associated with thisDocument
.int
hashCode()
boolean
hasId()
Return true if thisDocument
is associated with an identifier.boolean
Return true if thisDocument
is associated with a primary_term.boolean
hasSeqNo()
Return true if thisDocument
is associated with a seq_no.boolean
Return true if thisDocument
is associated with a version.boolean
isEmpty()
keySet()
void
boolean
void
Set the identifier for thisDocument
.void
setPrimaryTerm
(long primaryTerm) Set the primary_term for thisDocument
.void
setSeqNo
(long seqNo) Set the seq_no for thisDocument
.void
setVersion
(long version) Set the version for thisDocument
.int
size()
toJson()
Render thisDocument
to JSON.toString()
values()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.elasticsearch.core.document.Document
fromJson, setIndex, transform
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, getOrDefault, merge, putIfAbsent, replace, replace, replaceAll
Methods inherited from interface org.springframework.data.elasticsearch.core.document.SearchDocument
getFieldValue
Methods inherited from interface org.springframework.data.elasticsearch.support.StringObjectMap
getBoolean, getBooleanOrDefault, getBooleanOrDefault, getInt, getIntOrDefault, getIntOrDefault, getLong, getLongOrDefault, getLongOrDefault, getString, getStringOrDefault, getStringOrDefault
-
Constructor Details
-
SearchDocumentAdapter
public SearchDocumentAdapter(Document delegate, float score, Object[] sortValues, Map<String, List<Object>> fields, Map<String, List<String>> highlightFields, Map<String, SearchDocumentResponse> innerHits, @Nullable NestedMetaData nestedMetaData, @Nullable Explanation explanation, @Nullable List<String> matchedQueries, @Nullable String routing)
-
-
Method Details
-
append
Description copied from interface:StringObjectMap
- Specified by:
append
in interfaceStringObjectMap<Document>
- Parameters:
key
- key with which the specified value is to be associated. must not be null.value
- value to be associated with the specified key.- Returns:
this
object.
-
getScore
public float getScore()Description copied from interface:SearchDocument
Return the searchscore
.- Specified by:
getScore
in interfaceSearchDocument
- Returns:
- the search
score
.
-
getFields
- Specified by:
getFields
in interfaceSearchDocument
- Returns:
- the fields for the search result, not null
-
getSortValues
- Specified by:
getSortValues
in interfaceSearchDocument
- Returns:
- the sort values for the search hit
-
getHighlightFields
- Specified by:
getHighlightFields
in interfaceSearchDocument
- Returns:
- the highlightFields for the search hit.
-
getIndex
-
hasId
public boolean hasId()Description copied from interface:Document
Return true if thisDocument
is associated with an identifier. -
getId
Description copied from interface:Document
Retrieve the identifier associated with thisDocument
.The default implementation throws
UnsupportedOperationException
. It's recommended to checkDocument.hasId()
prior to calling this method. -
setId
Description copied from interface:Document
Set the identifier for thisDocument
.The default implementation throws
UnsupportedOperationException
. -
hasVersion
public boolean hasVersion()Description copied from interface:Document
Return true if thisDocument
is associated with a version.- Specified by:
hasVersion
in interfaceDocument
- Returns:
- true if this
Document
is associated with a version, false otherwise.
-
getVersion
public long getVersion()Description copied from interface:Document
Retrieve the version associated with thisDocument
.The default implementation throws
UnsupportedOperationException
. It's recommended to checkDocument.hasVersion()
prior to calling this method.- Specified by:
getVersion
in interfaceDocument
- Returns:
- the version associated with this
Document
.
-
setVersion
public void setVersion(long version) Description copied from interface:Document
Set the version for thisDocument
.The default implementation throws
UnsupportedOperationException
.- Specified by:
setVersion
in interfaceDocument
-
hasSeqNo
public boolean hasSeqNo()Description copied from interface:Document
Return true if thisDocument
is associated with a seq_no. -
getSeqNo
public long getSeqNo()Description copied from interface:Document
Retrieve the seq_no associated with thisDocument
.The default implementation throws
UnsupportedOperationException
. It's recommended to checkDocument.hasSeqNo()
prior to calling this method. -
setSeqNo
public void setSeqNo(long seqNo) Description copied from interface:Document
Set the seq_no for thisDocument
.The default implementation throws
UnsupportedOperationException
. -
hasPrimaryTerm
public boolean hasPrimaryTerm()Description copied from interface:Document
Return true if thisDocument
is associated with a primary_term.- Specified by:
hasPrimaryTerm
in interfaceDocument
- Returns:
- true if this
Document
is associated with a primary_term, false otherwise.
-
getPrimaryTerm
public long getPrimaryTerm()Description copied from interface:Document
Retrieve the primary_term associated with thisDocument
.The default implementation throws
UnsupportedOperationException
. It's recommended to checkDocument.hasPrimaryTerm()
prior to calling this method.- Specified by:
getPrimaryTerm
in interfaceDocument
- Returns:
- the primary_term associated with this
Document
.
-
setPrimaryTerm
public void setPrimaryTerm(long primaryTerm) Description copied from interface:Document
Set the primary_term for thisDocument
.The default implementation throws
UnsupportedOperationException
.- Specified by:
setPrimaryTerm
in interfaceDocument
-
getInnerHits
- Specified by:
getInnerHits
in interfaceSearchDocument
- Returns:
- the innerHits for the SearchHit
-
getNestedMetaData
- Specified by:
getNestedMetaData
in interfaceSearchDocument
- Returns:
- the nested metadata in case this is a nested inner hit.
-
get
Description copied from interface:StringObjectMap
Returns the value to which the specifiedkey
is mapped, or null if this document contains no mapping for the key. The value is casted within the method which makes it useful for calling code as it does not require casting on the calling side. If the value type is not assignable totype
, then this method throwsClassCastException
.- Specified by:
get
in interfaceStringObjectMap<Document>
- Type Parameters:
T
- expected return type.- Parameters:
key
- the key whose associated value is to be returnedtype
- the expected return value type.- Returns:
- the value to which the specified key is mapped, or null if this document contains no mapping for the key.
-
toJson
Description copied from interface:StringObjectMap
Render thisDocument
to JSON. Auxiliary values such as Id and version are not considered within the JSON representation.- Specified by:
toJson
in interfaceStringObjectMap<Document>
- Returns:
- a JSON representation of this document.
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
Object>
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
Object>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
getExplanation
- Specified by:
getExplanation
in interfaceSearchDocument
- Returns:
- the explanation for the SearchHit.
-
getMatchedQueries
- Specified by:
getMatchedQueries
in interfaceSearchDocument
- Returns:
- the matched queries for the SearchHit.
-
equals
-
hashCode
public int hashCode() -
forEach
-
remove
-
getRouting
- Specified by:
getRouting
in interfaceSearchDocument
- Returns:
- the routing value for the document
-
toString
-