Package org.elasticsearch.search
Class SearchHits
- java.lang.Object
-
- org.elasticsearch.search.SearchHits
-
- All Implemented Interfaces:
Iterable<SearchHit>,Writeable,ToXContent,ToXContentFragment
public final class SearchHits extends Object implements Writeable, ToXContentFragment, Iterable<SearchHit>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSearchHits.Fields-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description static SearchHit[]EMPTY-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description SearchHits(StreamInput in)SearchHits(SearchHit[] hits, TotalHits totalHits, float maxScore)SearchHits(SearchHit[] hits, TotalHits totalHits, float maxScore, SortField[] sortFields, String collapseField, Object[] collapseValues)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SearchHitsempty()static SearchHitsempty(boolean withTotalHits)booleanequals(Object obj)static SearchHitsfromXContent(XContentParser parser)SearchHitgetAt(int position)Return the hit as the provided position.StringgetCollapseField()In case field collapsing was performed, returns the field used for field collapsing, null otherwiseObject[]getCollapseValues()In case field collapsing was performed, returns the values of the field that field collapsing was performed on, null otherwiseSearchHit[]getHits()The hits of the search request (based on the search type, and from / size provided).floatgetMaxScore()The maximum score of this query.SortField[]getSortFields()In case documents were sorted by field(s), returns information about such field(s), null otherwiseTotalHitsgetTotalHits()The total number of hits for the query or null if the tracking of total hits is disabled in the request.inthashCode()Iterator<SearchHit>iterator()static TotalHitsparseTotalHitsFragment(XContentParser parser)XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
EMPTY
public static final SearchHit[] EMPTY
-
-
Constructor Detail
-
SearchHits
public SearchHits(SearchHit[] hits, @Nullable TotalHits totalHits, float maxScore, @Nullable SortField[] sortFields, @Nullable String collapseField, @Nullable Object[] collapseValues)
-
SearchHits
public SearchHits(StreamInput in) throws IOException
- Throws:
IOException
-
-
Method Detail
-
empty
public static SearchHits empty()
-
empty
public static SearchHits empty(boolean withTotalHits)
-
writeTo
public void writeTo(StreamOutput out) throws IOException
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getTotalHits
@Nullable public TotalHits getTotalHits()
The total number of hits for the query or null if the tracking of total hits is disabled in the request.
-
getMaxScore
public float getMaxScore()
The maximum score of this query.
-
getHits
public SearchHit[] getHits()
The hits of the search request (based on the search type, and from / size provided).
-
getAt
public SearchHit getAt(int position)
Return the hit as the provided position.
-
getSortFields
@Nullable public SortField[] getSortFields()
In case documents were sorted by field(s), returns information about such field(s), null otherwise- See Also:
SortField
-
getCollapseField
@Nullable public String getCollapseField()
In case field collapsing was performed, returns the field used for field collapsing, null otherwise
-
getCollapseValues
@Nullable public Object[] getCollapseValues()
In case field collapsing was performed, returns the values of the field that field collapsing was performed on, null otherwise
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
fromXContent
public static SearchHits fromXContent(XContentParser parser) throws IOException
- Throws:
IOException
-
parseTotalHitsFragment
public static TotalHits parseTotalHitsFragment(XContentParser parser) throws IOException
- Throws:
IOException
-
-