java.lang.Iterable<DocumentField>
, Streamable
, ToXContent
, ToXContentObject
public final class SearchHit extends java.lang.Object implements Streamable, ToXContentObject, java.lang.Iterable<DocumentField>
SearchHits
Modifier and Type | Class | Description |
---|---|---|
static class |
SearchHit.Fields |
|
static class |
SearchHit.NestedIdentity |
Encapsulates the nested identity of a hit.
|
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
EMPTY_PARAMS
Constructor | Description |
---|---|
SearchHit(int docId) |
|
SearchHit(int docId,
java.lang.String id,
Text type,
java.util.Map<java.lang.String,DocumentField> fields) |
|
SearchHit(int nestedTopDocId,
java.lang.String id,
Text type,
SearchHit.NestedIdentity nestedIdentity,
java.util.Map<java.lang.String,DocumentField> fields) |
Modifier and Type | Method | Description |
---|---|---|
static SearchHit |
createFromMap(java.util.Map<java.lang.String,java.lang.Object> values) |
|
static void |
declareInnerHitsParseFields(ObjectParser<java.util.Map<java.lang.String,java.lang.Object>,java.lang.Void> parser) |
|
int |
docId() |
|
boolean |
equals(java.lang.Object obj) |
|
void |
explanation(org.apache.lucene.search.Explanation explanation) |
|
DocumentField |
field(java.lang.String fieldName) |
The hit field matching the given field name.
|
void |
fields(java.util.Map<java.lang.String,DocumentField> fields) |
|
java.util.Map<java.lang.String,DocumentField> |
fieldsOrNull() |
|
static SearchHit |
fromXContent(XContentParser parser) |
|
java.lang.String |
getClusterAlias() |
Returns the cluster alias this hit comes from or null if it comes from a local cluster
|
org.apache.lucene.search.Explanation |
getExplanation() |
If enabled, the explanation of the search hit.
|
java.util.Map<java.lang.String,DocumentField> |
getFields() |
A map of hit fields (from field name to hit fields) if additional fields
were required to be loaded.
|
java.util.Map<java.lang.String,HighlightField> |
getHighlightFields() |
A map of highlighted fields.
|
java.lang.String |
getId() |
The id of the document.
|
java.lang.String |
getIndex() |
The index of the hit.
|
java.util.Map<java.lang.String,SearchHits> |
getInnerHits() |
|
java.lang.String[] |
getMatchedQueries() |
The set of query and filter names the query matched with.
|
SearchHit.NestedIdentity |
getNestedIdentity() |
If this is a nested hit then nested reference information is returned otherwise
null is returned. |
float |
getScore() |
The score.
|
SearchShardTarget |
getShard() |
The shard of the search hit.
|
java.lang.Object[] |
getSortValues() |
An array of the sort values used.
|
java.util.Map<java.lang.String,java.lang.Object> |
getSourceAsMap() |
The source of the document as a map (can be null).
|
java.lang.String |
getSourceAsString() |
The source of the document as string (can be null).
|
BytesReference |
getSourceRef() |
Returns bytes reference, also uncompress the source if needed.
|
java.lang.String |
getType() |
The type of the document.
|
long |
getVersion() |
The version of the hit.
|
int |
hashCode() |
|
boolean |
hasSource() |
Is the source available or not.
|
void |
highlightFields(java.util.Map<java.lang.String,HighlightField> highlightFields) |
|
java.util.Iterator<DocumentField> |
iterator() |
|
void |
matchedQueries(java.lang.String[] matchedQueries) |
|
void |
readFrom(StreamInput in) |
Set this object's fields from a StreamInput.
|
static SearchHit |
readSearchHit(StreamInput in) |
|
void |
score(float score) |
|
void |
setInnerHits(java.util.Map<java.lang.String,SearchHits> innerHits) |
|
void |
shard(SearchShardTarget target) |
|
void |
sortValues(java.lang.Object[] sortValues,
DocValueFormat[] sortValueFormats) |
|
void |
sortValues(SearchSortValues sortValues) |
|
SearchHit |
sourceRef(BytesReference source) |
Sets representation, might be compressed....
|
XContentBuilder |
toInnerXContent(XContentBuilder builder,
ToXContent.Params params) |
|
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
|
void |
version(long version) |
|
void |
writeTo(StreamOutput out) |
Write this object's fields to a StreamOutput.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
isFragment
public SearchHit(int docId)
public SearchHit(int docId, java.lang.String id, Text type, java.util.Map<java.lang.String,DocumentField> fields)
public SearchHit(int nestedTopDocId, java.lang.String id, Text type, SearchHit.NestedIdentity nestedIdentity, java.util.Map<java.lang.String,DocumentField> fields)
public int docId()
public void score(float score)
public float getScore()
public void version(long version)
public long getVersion()
public java.lang.String getIndex()
public java.lang.String getId()
public java.lang.String getType()
public SearchHit.NestedIdentity getNestedIdentity()
null
is returned.public BytesReference getSourceRef()
public SearchHit sourceRef(BytesReference source)
public boolean hasSource()
fields
doesn't contain
_source
or if source is disabled in the mapping.public java.lang.String getSourceAsString()
public java.util.Map<java.lang.String,java.lang.Object> getSourceAsMap()
public java.util.Iterator<DocumentField> iterator()
iterator
in interface java.lang.Iterable<DocumentField>
public DocumentField field(java.lang.String fieldName)
public java.util.Map<java.lang.String,DocumentField> getFields()
public java.util.Map<java.lang.String,DocumentField> fieldsOrNull()
public void fields(java.util.Map<java.lang.String,DocumentField> fields)
public java.util.Map<java.lang.String,HighlightField> getHighlightFields()
public void highlightFields(java.util.Map<java.lang.String,HighlightField> highlightFields)
public void sortValues(java.lang.Object[] sortValues, DocValueFormat[] sortValueFormats)
public void sortValues(SearchSortValues sortValues)
public java.lang.Object[] getSortValues()
public org.apache.lucene.search.Explanation getExplanation()
public void explanation(org.apache.lucene.search.Explanation explanation)
public SearchShardTarget getShard()
public void shard(SearchShardTarget target)
public java.lang.String getClusterAlias()
public void matchedQueries(java.lang.String[] matchedQueries)
public java.lang.String[] getMatchedQueries()
public java.util.Map<java.lang.String,SearchHits> getInnerHits()
null
if there are nonepublic void setInnerHits(java.util.Map<java.lang.String,SearchHits> innerHits)
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
toXContent
in interface ToXContent
java.io.IOException
public XContentBuilder toInnerXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOException
public static SearchHit fromXContent(XContentParser parser)
public static void declareInnerHitsParseFields(ObjectParser<java.util.Map<java.lang.String,java.lang.Object>,java.lang.Void> parser)
public static SearchHit createFromMap(java.util.Map<java.lang.String,java.lang.Object> values)
public static SearchHit readSearchHit(StreamInput in) throws java.io.IOException
java.io.IOException
public void readFrom(StreamInput in) throws java.io.IOException
Streamable
readFrom
in interface Streamable
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Streamable
writeTo
in interface Streamable
java.io.IOException
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object