Package org.elasticsearch.search
Class SearchHit
org.elasticsearch.search.SearchHit
- All Implemented Interfaces:
<DocumentField>
,Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
A single search hit.
- See Also:
SearchHits
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
Encapsulates the nested identity of a hit.Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic org.elasticsearch.common.xcontent.ObjectParser.UnknownFieldConsumer<<,>>
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionSearchHit(int docId)
SearchHit(int docId, id, Text type, <,DocumentField> documentFields, <,DocumentField> metaFields)
SearchHit(int nestedTopDocId, id, Text type, SearchHit.NestedIdentity nestedIdentity, <,DocumentField> documentFields, <,DocumentField> metaFields)
SearchHit(StreamInput in)
-
Method Summary
Modifier and TypeMethodDescriptionstatic SearchHit
<,> values)
static void
<,>,> parser)
int
docId()
boolean
obj)
void
explanation(org.apache.lucene.search.Explanation explanation)
fieldName)
The hit field matching the given field name.static SearchHit
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
Returns the cluster alias this hit comes from or null if it comes from a local clusterorg.apache.lucene.search.Explanation
If enabled, the explanation of the search hit.<,DocumentField>
A map of hit fields (from field name to hit fields) if additional fields were required to be loaded.<,HighlightField>
A map of highlighted fields.getId()
The id of the document.getIndex()
The index of the hit.<,SearchHits>
[]
The set of query and filter names the query matched with.If this is a nested hit then nested reference information is returned otherwisenull
is returned.long
returns the primary term of the last modification to the document, orSequenceNumbers.UNASSIGNED_PRIMARY_TERM
if not requested.[]
An array of the (raw) sort values used.float
getScore()
The score.long
getSeqNo()
returns the sequence number of the last modification to the document, orSequenceNumbers.UNASSIGNED_SEQ_NO
if not requested.getShard()
The shard of the search hit.[]
An array of the (formatted) sort values used.<,>
The source of the document as a map (can benull
).The source of the document as string (can benull
).Returns bytes reference, also uncompress the source if needed.getType()
Deprecated.Types are in the process of being removed.long
The version of the hit.int
hashCode()
boolean
Is the source available or not.void
<,HighlightField> highlightFields)
iterator()
void
[] matchedQueries)
void
score(float score)
void
fieldName, DocumentField field)
void
<,SearchHits> innerHits)
void
setPrimaryTerm(long primaryTerm)
void
setSeqNo(long seqNo)
void
shard(SearchShardTarget target)
void
[] sortValues, DocValueFormat[] sortValueFormats)
void
sortValues(SearchSortValues sortValues)
sourceRef(BytesReference source)
Sets representation, might be compressed....org.elasticsearch.common.xcontent.XContentBuilder
toInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
toString()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
version(long version)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class java.lang.
, , , , , , ,
Methods inherited from interface java.lang.
,
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
Field Details
-
unknownMetaFieldConsumer
public static final org.elasticsearch.common.xcontent.ObjectParser.UnknownFieldConsumer<<,>> unknownMetaFieldConsumer
-
-
Constructor Details
-
SearchHit
public SearchHit(int docId) -
SearchHit
public SearchHit(int docId, id, Text type, <,DocumentField> documentFields, <,DocumentField> metaFields) -
SearchHit
public SearchHit(int nestedTopDocId, id, Text type, SearchHit.NestedIdentity nestedIdentity, <,DocumentField> documentFields, <,DocumentField> metaFields) -
SearchHit
- Throws:
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput. -
docId
public int docId() -
score
public void score(float score) -
getScore
public float getScore()The score. -
version
public void version(long version) -
getVersion
public long getVersion()The version of the hit. -
setSeqNo
public void setSeqNo(long seqNo) -
setPrimaryTerm
public void setPrimaryTerm(long primaryTerm) -
getSeqNo
public long getSeqNo()returns the sequence number of the last modification to the document, orSequenceNumbers.UNASSIGNED_SEQ_NO
if not requested. -
getPrimaryTerm
public long getPrimaryTerm()returns the primary term of the last modification to the document, orSequenceNumbers.UNASSIGNED_PRIMARY_TERM
if not requested. -
getIndex
public getIndex()The index of the hit. -
getId
public getId()The id of the document. -
getType
public getType()Deprecated.Types are in the process of being removed. Instead of using a type, prefer to filter on a field on the document.The type of the document. -
getNestedIdentity
If this is a nested hit then nested reference information is returned otherwisenull
is returned. -
getSourceRef
Returns bytes reference, also uncompress the source if needed. -
sourceRef
Sets representation, might be compressed.... -
hasSource
public boolean hasSource()Is the source available or not. A source with no fields will return true. This will return false iffields
doesn't contain_source
or if source is disabled in the mapping. -
getSourceAsString
public getSourceAsString()The source of the document as string (can benull
). -
getSourceAsMap
public <,> getSourceAsMap()The source of the document as a map (can benull
). -
iterator
- Specified by:
in interface
<DocumentField>
-
field
public fieldName)The hit field matching the given field name. -
setDocumentField
-
getFields
A map of hit fields (from field name to hit fields) if additional fields were required to be loaded. -
getHighlightFields
A map of highlighted fields. -
highlightFields
-
sortValues
-
sortValues
-
getSortValues
public [] getSortValues()An array of the (formatted) sort values used. -
getRawSortValues
public [] getRawSortValues()An array of the (raw) sort values used. -
getExplanation
public org.apache.lucene.search.Explanation getExplanation()If enabled, the explanation of the search hit. -
explanation
public void explanation(org.apache.lucene.search.Explanation explanation) -
getShard
The shard of the search hit. -
shard
-
getClusterAlias
public getClusterAlias()Returns the cluster alias this hit comes from or null if it comes from a local cluster -
matchedQueries
public void matchedQueries([] matchedQueries) -
getMatchedQueries
public [] getMatchedQueries()The set of query and filter names the query matched with. Mainly makes sense for compound filters and queries. -
getInnerHits
- Returns:
- Inner hits or
null
if there are none
-
setInnerHits
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
-
toInnerXContent
public org.elasticsearch.common.xcontent.XContentBuilder toInnerXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws- Throws:
-
fromXContent
-
declareInnerHitsParseFields
public static void declareInnerHitsParseFields(org.elasticsearch.common.xcontent.ObjectParser<<,>,> parser) -
createFromMap
public static <,> values) -
equals
public boolean equals( obj)- Overrides:
in class
-
hashCode
public int hashCode()- Overrides:
in class
-
toString
public toString()- Overrides:
in class
-