Class SearchHits

java.lang.Object
org.elasticsearch.search.SearchHits
All Implemented Interfaces:
Iterable<SearchHit>, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment

public final class SearchHits extends Object implements Writeable, org.elasticsearch.common.xcontent.ToXContentFragment, Iterable<SearchHit>
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    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

    Fields
    Modifier and Type
    Field
    Description
    static SearchHit[]
     

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    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, String collapseField, Object[] collapseValues)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static SearchHits
     
    static SearchHits
    empty​(boolean withTotalHits)
     
    boolean
    equals​(Object obj)
     
    static SearchHits
    fromXContent​(org.elasticsearch.common.xcontent.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 otherwise
    In case field collapsing was performed, returns the values of the field that field collapsing was performed on, null otherwise
    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 otherwise
    org.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
     
     
    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
    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 Details

    • EMPTY

      public static final SearchHit[] EMPTY
  • 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 String collapseField, @Nullable Object[] collapseValues)
    • SearchHits

      public SearchHits(StreamInput in) throws IOException
      Throws:
      IOException
  • Method Details

    • empty

      public static SearchHits empty()
    • empty

      public static SearchHits empty(boolean withTotalHits)
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • 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

      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 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 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
    • iterator

      public Iterator<SearchHit> iterator()
      Specified by:
      iterator in interface Iterable<SearchHit>
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      IOException
    • fromXContent

      public static SearchHits fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException
      Throws:
      IOException
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • parseTotalHitsFragment

      public static org.apache.lucene.search.TotalHits parseTotalHitsFragment(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException
      Throws:
      IOException