public class SearchHit extends java.lang.Object implements Streamable, ToXContentObject, java.lang.Iterable<SearchHitField>
SearchHits| Modifier and Type | Class and Description |
|---|---|
static class |
SearchHit.Fields |
static class |
SearchHit.NestedIdentity
Encapsulates the nested identity of a hit.
|
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsEMPTY_PARAMS| Constructor and Description |
|---|
SearchHit(int docId) |
SearchHit(int docId,
java.lang.String id,
Text type,
java.util.Map<java.lang.String,SearchHitField> fields) |
SearchHit(int nestedTopDocId,
java.lang.String id,
Text type,
SearchHit.NestedIdentity nestedIdentity,
java.util.Map<java.lang.String,SearchHitField> fields) |
| Modifier and Type | Method and 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() |
org.apache.lucene.search.Explanation |
explanation()
Deprecated.
use
getExplanation() instead |
void |
explanation(org.apache.lucene.search.Explanation explanation) |
SearchHitField |
field(java.lang.String fieldName)
Deprecated.
use
getField(String) instead |
java.util.Map<java.lang.String,SearchHitField> |
fields()
Deprecated.
use
getFields() instead |
void |
fields(java.util.Map<java.lang.String,SearchHitField> fields) |
java.util.Map<java.lang.String,SearchHitField> |
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.
|
SearchHitField |
getField(java.lang.String fieldName)
The hit field matching the given field name.
|
java.util.Map<java.lang.String,SearchHitField> |
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> |
getSource()
The source of the document as a map (can be null).
|
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.
|
boolean |
hasSource()
Is the source available or not.
|
java.util.Map<java.lang.String,HighlightField> |
highlightFields()
Deprecated.
use
getHighlightFields() instead |
void |
highlightFields(java.util.Map<java.lang.String,HighlightField> highlightFields) |
java.lang.String |
id()
Deprecated.
use
getId() instead |
java.lang.String |
index()
Deprecated.
use
getIndex() instead |
java.util.Iterator<SearchHitField> |
iterator() |
java.lang.String[] |
matchedQueries()
Deprecated.
|
void |
matchedQueries(java.lang.String[] matchedQueries) |
void |
readFrom(StreamInput in)
Set this object's fields from a StreamInput.
|
static SearchHit |
readSearchHit(StreamInput in) |
float |
score()
Deprecated.
use
getScore() instead |
void |
score(float score) |
void |
setInnerHits(java.util.Map<java.lang.String,SearchHits> innerHits) |
SearchShardTarget |
shard()
Deprecated.
use
getShard() instead |
void |
shard(SearchShardTarget target) |
java.lang.Object[] |
sortValues()
Deprecated.
use
getSortValues() instead |
void |
sortValues(java.lang.Object[] sortValues,
DocValueFormat[] sortValueFormats) |
void |
sortValues(SearchSortValues sortValues) |
byte[] |
source()
Deprecated.
|
java.util.Map<java.lang.String,java.lang.Object> |
sourceAsMap()
Deprecated.
use
getSourceAsMap() instgead |
java.lang.String |
sourceAsString()
Deprecated.
use
getSourceAsString() instead |
BytesReference |
sourceRef()
Deprecated.
use
getSourceRef() instead |
SearchHit |
sourceRef(BytesReference source)
Sets representation, might be compressed....
|
XContentBuilder |
toInnerXContent(XContentBuilder builder,
ToXContent.Params params) |
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
java.lang.String |
type()
Deprecated.
use
getType() instead |
long |
version()
Deprecated.
use
getVersion() instead |
void |
version(long version) |
void |
writeTo(StreamOutput out)
Write this object's fields to a StreamOutput.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisFragmentpublic SearchHit(int docId)
public SearchHit(int docId,
java.lang.String id,
Text type,
java.util.Map<java.lang.String,SearchHitField> fields)
public SearchHit(int nestedTopDocId,
java.lang.String id,
Text type,
SearchHit.NestedIdentity nestedIdentity,
java.util.Map<java.lang.String,SearchHitField> fields)
public int docId()
public void score(float score)
@Deprecated public float score()
getScore() insteadpublic float getScore()
public void version(long version)
@Deprecated public long version()
getVersion() insteadpublic long getVersion()
@Deprecated public java.lang.String index()
getIndex() insteadpublic java.lang.String getIndex()
@Deprecated public java.lang.String id()
getId() insteadpublic java.lang.String getId()
@Deprecated public java.lang.String type()
getType() insteadpublic java.lang.String getType()
public SearchHit.NestedIdentity getNestedIdentity()
null is returned.@Deprecated public BytesReference sourceRef()
getSourceRef() insteadpublic SearchHit sourceRef(BytesReference source)
public BytesReference getSourceRef()
@Deprecated public byte[] source()
sourceRef() so there won't be a need to copy.public boolean hasSource()
fields doesn't contain
_source or if source is disabled in the mapping.public java.util.Map<java.lang.String,java.lang.Object> getSource()
@Deprecated public java.lang.String sourceAsString()
getSourceAsString() insteadpublic java.lang.String getSourceAsString()
@Deprecated
public java.util.Map<java.lang.String,java.lang.Object> sourceAsMap()
throws ElasticsearchParseException
getSourceAsMap() instgeadElasticsearchParseExceptionpublic java.util.Map<java.lang.String,java.lang.Object> getSourceAsMap()
throws ElasticsearchParseException
ElasticsearchParseExceptionpublic java.util.Iterator<SearchHitField> iterator()
iterator in interface java.lang.Iterable<SearchHitField>@Deprecated public SearchHitField field(java.lang.String fieldName)
getField(String) insteadpublic SearchHitField getField(java.lang.String fieldName)
@Deprecated public java.util.Map<java.lang.String,SearchHitField> fields()
getFields() insteadpublic java.util.Map<java.lang.String,SearchHitField> fieldsOrNull()
public java.util.Map<java.lang.String,SearchHitField> getFields()
public void fields(java.util.Map<java.lang.String,SearchHitField> fields)
@Deprecated public java.util.Map<java.lang.String,HighlightField> highlightFields()
getHighlightFields() insteadpublic 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)
@Deprecated public java.lang.Object[] sortValues()
getSortValues() insteadpublic java.lang.Object[] getSortValues()
@Deprecated public org.apache.lucene.search.Explanation explanation()
getExplanation() insteadpublic org.apache.lucene.search.Explanation getExplanation()
public void explanation(org.apache.lucene.search.Explanation explanation)
@Deprecated public SearchShardTarget shard()
getShard() insteadpublic SearchShardTarget getShard()
public void shard(SearchShardTarget target)
public java.lang.String getClusterAlias()
public void matchedQueries(java.lang.String[] matchedQueries)
@Deprecated public 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 ToXContentjava.io.IOExceptionpublic XContentBuilder toInnerXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOExceptionpublic 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.IOExceptionpublic void readFrom(StreamInput in) throws java.io.IOException
StreamablereadFrom in interface Streamablejava.io.IOExceptionpublic void writeTo(StreamOutput out) throws java.io.IOException
StreamablewriteTo in interface Streamablejava.io.IOException