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>
  • Field Details

    • EMPTY

      public static final SearchHit[] EMPTY
  • Constructor Details

  • 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 XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException
    • fromXContent

      public static SearchHits fromXContent(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(XContentParser parser) throws IOException
      Throws:
      IOException