Package org.elasticsearch.search
Class SearchHits
java.lang.Object
org.elasticsearch.search.SearchHits
- All Implemented Interfaces:
java.lang.Iterable<SearchHit>
,Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
public final class SearchHits extends java.lang.Object implements Writeable, org.elasticsearch.common.xcontent.ToXContentFragment, java.lang.Iterable<SearchHit>
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SearchHits.Fields
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
-
Constructor Summary
Constructors Constructor Description SearchHits(StreamInput in)
SearchHits(SearchHit[] hits, org.apache.lucene.search.TotalHits totalHits, float maxScore)
SearchHits(SearchHit[] hits, org.apache.lucene.search.TotalHits totalHits, float maxScore, org.apache.lucene.search.SortField[] sortFields, java.lang.String collapseField, java.lang.Object[] collapseValues)
-
Method Summary
Modifier and Type Method Description static SearchHits
empty()
static SearchHits
empty(boolean withTotalHits)
boolean
equals(java.lang.Object obj)
static SearchHits
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
SearchHit
getAt(int position)
Return the hit as the provided position.java.lang.String
getCollapseField()
In case field collapsing was performed, returns the field used for field collapsing, null otherwisejava.lang.Object[]
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).float
getMaxScore()
The maximum score of this query.org.apache.lucene.search.SortField[]
getSortFields()
In case documents were sorted by field(s), returns information about such field(s), null otherwiseorg.apache.lucene.search.TotalHits
getTotalHits()
The total number of hits for the query or null if the tracking of total hits is disabled in the request.int
hashCode()
java.util.Iterator<SearchHit>
iterator()
static org.apache.lucene.search.TotalHits
parseTotalHitsFragment(org.elasticsearch.common.xcontent.XContentParser parser)
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.
-
Field Details
-
Constructor Details
-
SearchHits
public SearchHits(SearchHit[] hits, @Nullable org.apache.lucene.search.TotalHits totalHits, float maxScore) -
SearchHits
public SearchHits(SearchHit[] hits, @Nullable org.apache.lucene.search.TotalHits totalHits, float maxScore, @Nullable org.apache.lucene.search.SortField[] sortFields, @Nullable java.lang.String collapseField, @Nullable java.lang.Object[] collapseValues) -
SearchHits
- Throws:
java.io.IOException
-
-
Method Details
-
empty
-
empty
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput. -
getTotalHits
@Nullable public org.apache.lucene.search.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
The hits of the search request (based on the search type, and from / size provided). -
getAt
Return the hit as the provided position. -
getSortFields
@Nullable public org.apache.lucene.search.SortField[] getSortFields()In case documents were sorted by field(s), returns information about such field(s), null otherwise- See Also:
SortField
-
getCollapseField
@Nullable public java.lang.String getCollapseField()In case field collapsing was performed, returns the field used for field collapsing, null otherwise -
getCollapseValues
@Nullable public java.lang.Object[] getCollapseValues()In case field collapsing was performed, returns the values of the field that field collapsing was performed on, null otherwise -
iterator
- Specified by:
iterator
in interfacejava.lang.Iterable<SearchHit>
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
java.io.IOException
-
fromXContent
public static SearchHits fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
parseTotalHitsFragment
public static org.apache.lucene.search.TotalHits parseTotalHitsFragment(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-