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 TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanvoidforEach(BiConsumer<? super String, ? super Object> action) <T> TReturns the value to which the specifiedkeyis mapped, or null if this document contains no mapping for the key.getId()Retrieve the identifier associated with thisDocument.getIndex()longRetrieve the primary_term associated with thisDocument.floatgetScore()Return the searchscore.longgetSeqNo()Retrieve the seq_no associated with thisDocument.Object[]longRetrieve the version associated with thisDocument.inthashCode()booleanhasId()Return true if thisDocumentis associated with an identifier.booleanReturn true if thisDocumentis associated with a primary_term.booleanhasSeqNo()Return true if thisDocumentis associated with a seq_no.booleanReturn true if thisDocumentis associated with a version.booleanisEmpty()keySet()voidbooleanvoidSet the identifier for thisDocument.voidsetPrimaryTerm(long primaryTerm) Set the primary_term for thisDocument.voidsetSeqNo(long seqNo) Set the seq_no for thisDocument.voidsetVersion(long version) Set the version for thisDocument.intsize()toJson()Render thisDocumentto JSON.toString()values()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.elasticsearch.core.document.Document
fromJson, setIndex, transformMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, getOrDefault, merge, putIfAbsent, replace, replace, replaceAllMethods inherited from interface org.springframework.data.elasticsearch.core.document.SearchDocument
getFieldValue, getFieldValuesMethods 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:
appendin 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:
thisobject.
-
getScore
public float getScore()Description copied from interface:SearchDocumentReturn the searchscore.- Specified by:
getScorein interfaceSearchDocument- Returns:
- the search
score.
-
getFields
- Specified by:
getFieldsin interfaceSearchDocument- Returns:
- the fields for the search result, not null
-
getSortValues
- Specified by:
getSortValuesin interfaceSearchDocument- Returns:
- the sort values for the search hit
-
getHighlightFields
- Specified by:
getHighlightFieldsin interfaceSearchDocument- Returns:
- the highlightFields for the search hit.
-
getIndex
-
hasId
public boolean hasId()Description copied from interface:DocumentReturn true if thisDocumentis associated with an identifier. -
getId
Description copied from interface:DocumentRetrieve 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:DocumentSet the identifier for thisDocument.The default implementation throws
UnsupportedOperationException. -
hasVersion
public boolean hasVersion()Description copied from interface:DocumentReturn true if thisDocumentis associated with a version.- Specified by:
hasVersionin interfaceDocument- Returns:
- true if this
Documentis associated with a version, false otherwise.
-
getVersion
public long getVersion()Description copied from interface:DocumentRetrieve the version associated with thisDocument.The default implementation throws
UnsupportedOperationException. It's recommended to checkDocument.hasVersion()prior to calling this method.- Specified by:
getVersionin interfaceDocument- Returns:
- the version associated with this
Document.
-
setVersion
public void setVersion(long version) Description copied from interface:DocumentSet the version for thisDocument.The default implementation throws
UnsupportedOperationException.- Specified by:
setVersionin interfaceDocument
-
hasSeqNo
public boolean hasSeqNo()Description copied from interface:DocumentReturn true if thisDocumentis associated with a seq_no. -
getSeqNo
public long getSeqNo()Description copied from interface:DocumentRetrieve 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:DocumentSet the seq_no for thisDocument.The default implementation throws
UnsupportedOperationException. -
hasPrimaryTerm
public boolean hasPrimaryTerm()Description copied from interface:DocumentReturn true if thisDocumentis associated with a primary_term.- Specified by:
hasPrimaryTermin interfaceDocument- Returns:
- true if this
Documentis associated with a primary_term, false otherwise.
-
getPrimaryTerm
public long getPrimaryTerm()Description copied from interface:DocumentRetrieve the primary_term associated with thisDocument.The default implementation throws
UnsupportedOperationException. It's recommended to checkDocument.hasPrimaryTerm()prior to calling this method.- Specified by:
getPrimaryTermin interfaceDocument- Returns:
- the primary_term associated with this
Document.
-
setPrimaryTerm
public void setPrimaryTerm(long primaryTerm) Description copied from interface:DocumentSet the primary_term for thisDocument.The default implementation throws
UnsupportedOperationException.- Specified by:
setPrimaryTermin interfaceDocument
-
getInnerHits
- Specified by:
getInnerHitsin interfaceSearchDocument- Returns:
- the innerHits for the SearchHit
-
getNestedMetaData
- Specified by:
getNestedMetaDatain interfaceSearchDocument- Returns:
- the nested metadata in case this is a nested inner hit.
-
get
Description copied from interface:StringObjectMapReturns the value to which the specifiedkeyis 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:
getin 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:StringObjectMapRender thisDocumentto JSON. Auxiliary values such as Id and version are not considered within the JSON representation.- Specified by:
toJsonin interfaceStringObjectMap<Document>- Returns:
- a JSON representation of this document.
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKeyin interfaceMap<String,Object>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,Object>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
getExplanation
- Specified by:
getExplanationin interfaceSearchDocument- Returns:
- the explanation for the SearchHit.
-
getMatchedQueries
- Specified by:
getMatchedQueriesin interfaceSearchDocument- Returns:
- the matched queries for the SearchHit.
-
equals
-
hashCode
public int hashCode() -
forEach
-
remove
-
getRouting
- Specified by:
getRoutingin interfaceSearchDocument- Returns:
- the routing value for the document
-
toString
-