java.lang.Object
org.elasticsearch.search.SearchHits
- All Implemented Interfaces:
Iterable<SearchHit>
,Writeable
,ChunkedToXContent
,RefCounted
public final class SearchHits
extends Object
implements Writeable, ChunkedToXContent, RefCounted, Iterable<SearchHit>
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SearchHit[]
static final SearchHits
static final SearchHits
Fields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED
-
Constructor Summary
ConstructorsConstructorDescriptionSearchHits
(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, String collapseField, Object[] collapseValues) -
Method Summary
Modifier and TypeMethodDescriptionboolean
decRef()
static SearchHits
empty
(org.apache.lucene.search.TotalHits totalHits, float maxScore) boolean
static SearchHits
fromXContent
(XContentParser parser) getAt
(int position) Return the hit as the provided position.In case field collapsing was performed, returns the field used for field collapsing, null otherwiseObject[]
In case field collapsing was performed, returns the values of the field that field collapsing was performed on, null otherwisegetHits()
The hits of the search request (based on the search type, and from / size provided).float
The maximum score of this query.org.apache.lucene.search.SortField[]
In case documents were sorted by field(s), returns information about such field(s), null otherwiseorg.apache.lucene.search.TotalHits
The total number of hits for the query or null if the tracking of total hits is disabled in the request.int
hashCode()
boolean
void
incRef()
iterator()
static org.apache.lucene.search.TotalHits
parseTotalHitsFragment
(XContentParser parser) static SearchHits
readFrom
(StreamInput in, boolean pooled) Iterator<? extends ToXContent>
toXContentChunked
(ToXContent.Params params) Create an iterator ofToXContent
chunks for a REST response.boolean
static SearchHits
static SearchHits
unpooled
(SearchHit[] hits, org.apache.lucene.search.TotalHits totalHits, float maxScore, org.apache.lucene.search.SortField[] sortFields, String collapseField, Object[] collapseValues) void
writeTo
(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 org.elasticsearch.common.xcontent.ChunkedToXContent
isFragment, toXContentChunkedV7
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface org.elasticsearch.core.RefCounted
mustIncRef
-
Field Details
-
EMPTY
-
EMPTY_WITH_TOTAL_HITS
-
EMPTY_WITHOUT_TOTAL_HITS
-
-
Constructor Details
-
SearchHits
-
SearchHits
-
-
Method Details
-
empty
public static SearchHits empty(@Nullable org.apache.lucene.search.TotalHits totalHits, float maxScore) -
unpooled
public static SearchHits unpooled(SearchHit[] hits, @Nullable org.apache.lucene.search.TotalHits totalHits, float maxScore) -
unpooled
-
readFrom
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
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
In case documents were sorted by field(s), returns information about such field(s), null otherwise- See Also:
-
SortField
-
getCollapseField
In case field collapsing was performed, returns the field used for field collapsing, null otherwise -
getCollapseValues
In case field collapsing was performed, returns the values of the field that field collapsing was performed on, null otherwise -
iterator
-
incRef
public void incRef()- Specified by:
incRef
in interfaceRefCounted
-
tryIncRef
public boolean tryIncRef()- Specified by:
tryIncRef
in interfaceRefCounted
-
decRef
public boolean decRef()- Specified by:
decRef
in interfaceRefCounted
-
hasReferences
public boolean hasReferences()- Specified by:
hasReferences
in interfaceRefCounted
-
asUnpooled
-
toXContentChunked
Description copied from interface:ChunkedToXContent
Create an iterator ofToXContent
chunks for a REST response. Each chunk is serialized with the sameXContentBuilder
andToXContent.Params
, which is also the same as theToXContent.Params
passed as theparams
argument. For best results, all chunks should beO(1)
size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelper
for some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Specified by:
toXContentChunked
in interfaceChunkedToXContent
- Returns:
- iterator over chunks of
ToXContent
-
fromXContent
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
parseTotalHitsFragment
public static org.apache.lucene.search.TotalHits parseTotalHitsFragment(XContentParser parser) throws IOException - Throws:
IOException
-