Class SearchHit

    • Constructor Detail

      • SearchHit

        public SearchHit​(int docId)
      • SearchHit

        public SearchHit​(int docId,
                         java.lang.String id,
                         Text type,
                         java.util.Map<java.lang.String,​DocumentField> fields)
      • SearchHit

        public SearchHit​(StreamInput in)
                  throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • docId

        public int docId()
      • score

        public void score​(float score)
      • getScore

        public float getScore()
        The score.
      • version

        public void version​(long version)
      • getVersion

        public long getVersion()
        The version of the hit.
      • setSeqNo

        public void setSeqNo​(long seqNo)
      • setPrimaryTerm

        public void setPrimaryTerm​(long primaryTerm)
      • getIndex

        public java.lang.String getIndex()
        The index of the hit.
      • getId

        public java.lang.String getId()
        The id of the document.
      • getType

        @Deprecated
        public java.lang.String getType()
        Deprecated.
        Types are in the process of being removed. Instead of using a type, prefer to filter on a field on the document.
        The type of the document.
      • getNestedIdentity

        public SearchHit.NestedIdentity getNestedIdentity()
        If this is a nested hit then nested reference information is returned otherwise null is returned.
      • getSourceRef

        public BytesReference getSourceRef()
        Returns bytes reference, also uncompress the source if needed.
      • hasSource

        public boolean hasSource()
        Is the source available or not. A source with no fields will return true. This will return false if fields doesn't contain _source or if source is disabled in the mapping.
      • getSourceAsString

        public java.lang.String getSourceAsString()
        The source of the document as string (can be null).
      • getSourceAsMap

        public java.util.Map<java.lang.String,​java.lang.Object> getSourceAsMap()
        The source of the document as a map (can be null).
      • iterator

        public java.util.Iterator<DocumentField> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<DocumentField>
      • field

        public DocumentField field​(java.lang.String fieldName)
        The hit field matching the given field name.
      • getFields

        public java.util.Map<java.lang.String,​DocumentField> getFields()
        A map of hit fields (from field name to hit fields) if additional fields were required to be loaded.
      • fieldsOrNull

        public java.util.Map<java.lang.String,​DocumentField> fieldsOrNull()
      • fields

        public void fields​(java.util.Map<java.lang.String,​DocumentField> fields)
      • getHighlightFields

        public java.util.Map<java.lang.String,​HighlightField> getHighlightFields()
        A map of highlighted fields.
      • highlightFields

        public void highlightFields​(java.util.Map<java.lang.String,​HighlightField> highlightFields)
      • sortValues

        public void sortValues​(java.lang.Object[] sortValues,
                               DocValueFormat[] sortValueFormats)
      • getSortValues

        public java.lang.Object[] getSortValues()
        An array of the (formatted) sort values used.
      • getRawSortValues

        public java.lang.Object[] getRawSortValues()
        An array of the (raw) sort values used.
      • getExplanation

        public org.apache.lucene.search.Explanation getExplanation()
        If enabled, the explanation of the search hit.
      • explanation

        public void explanation​(org.apache.lucene.search.Explanation explanation)
      • getClusterAlias

        public java.lang.String getClusterAlias()
        Returns the cluster alias this hit comes from or null if it comes from a local cluster
      • matchedQueries

        public void matchedQueries​(java.lang.String[] matchedQueries)
      • getMatchedQueries

        public java.lang.String[] getMatchedQueries()
        The set of query and filter names the query matched with. Mainly makes sense for compound filters and queries.
      • getInnerHits

        public java.util.Map<java.lang.String,​SearchHits> getInnerHits()
        Returns:
        Inner hits or null if there are none
      • setInnerHits

        public void setInnerHits​(java.util.Map<java.lang.String,​SearchHits> innerHits)
      • declareInnerHitsParseFields

        public static void declareInnerHitsParseFields​(ObjectParser<java.util.Map<java.lang.String,​java.lang.Object>,​java.lang.Void> parser)
      • createFromMap

        public static SearchHit createFromMap​(java.util.Map<java.lang.String,​java.lang.Object> values)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object