Class FastHit

java.lang.Object
com.yahoo.component.provider.FreezableClass
com.yahoo.component.provider.ListenableFreezableClass
com.yahoo.search.result.Hit
com.yahoo.prelude.fastsearch.FastHit
All Implemented Interfaces:
com.yahoo.component.provider.Freezable, com.yahoo.component.provider.ListenableFreezable, com.yahoo.processing.response.Data, Cloneable, Comparable<Hit>

public class FastHit extends Hit
A regular hit from a Vespa backend
Author:
bratseth, Steinar Knutsen
  • Constructor Details

    • FastHit

      public FastHit()
      Creates an empty and temporarily invalid summary hit
    • FastHit

      public FastHit(byte[] gid, double relevance, int partId, int distributionKey)
    • FastHit

      public FastHit(byte[] gid, Relevance relevance, int partId, int distributionKey)
    • FastHit

      public FastHit(String uri, double relevancy)
  • Method Details

    • isMeta

      public boolean isMeta()
      Returns false - this is a concrete hit containing requested content
      Overrides:
      isMeta in class Hit
    • getId

      public com.yahoo.net.URI getId()
      Returns the explicitly set uri if available, returns "index:[source]/[partid]/[id]" otherwise
      Overrides:
      getId in class Hit
      Returns:
      uri of hit
    • getGlobalId

      public com.yahoo.document.GlobalId getGlobalId()
      Returns the global id of this document in the backend node which produced it
    • getRawGlobalId

      public byte[] getRawGlobalId()
    • setGlobalId

      public void setGlobalId(byte[] globalId)
    • getPartId

      public int getPartId()
    • getDistributionKey

      public int getDistributionKey()
      Returns the index of the node this hit originated at
    • setDistributionKey

      public void setDistributionKey(int distributionKey)
      Sets the index of the node this hit originated at
    • setSortData

      public void setSortData(byte[] data, Sorting sorting)
    • compareTo

      public int compareTo(Hit other)
      Description copied from class: Hit
      Compares this hit to another hit
      Specified by:
      compareTo in interface Comparable<Hit>
      Overrides:
      compareTo in class Hit
    • addSummary

      public void addSummary(DocsumDefinition docsumDef, com.yahoo.data.access.Inspector value)
      For internal use
    • features

      public FeatureData features()
      Returns values for the features listed in summary-features in the rank profile specified in the query producing this.
      Overrides:
      features in class Hit
    • getField

      public Object getField(String name)

      Returns a field value from this Hit. The value is either a stored value from the Document represented by this Hit, or a generated value added during later processing.

      The values available from the matching Document are a subset of the values set in the document, determined by the filled status of this Hit. More fields may be requested by requesting further filling.

      Lookups on names which does not exists in the document and is not added by later processing return null.

      Lookups on fields which exist in the document, in a summary class which is already requested filled returns the following types, even when the field has no actual value:

      • string and uri fields: A Java String.
        The empty string ("") if no value is assigned in the document.
      • Dynamic summary string fields: A Java String before JuniperSearcher and a HitField after.
      • Numerics: The corresponding numeric Java type.
        If the field has no value assigned in the document, the special numeric NanNumber.NaN is returned.
      • raw fields: A RawData instance
      • tensor fields: A Tensor instance
      • multivalue fields: A Inspector instance
      Overrides:
      getField in class Hit
    • setField

      public Object setField(String name, Object value)
      Description copied from class: Hit
      Sets the value of a field
      Overrides:
      setField in class Hit
      Returns:
      the previous value, or null if none
    • forEachField

      public void forEachField(BiConsumer<String,Object> consumer)
      Description copied from class: Hit
      Receive a callback on the given object for each field in this hit. This is more efficient than accessing the fields as a map or iterator.
      Overrides:
      forEachField in class Hit
    • forEachFieldAsRaw

      public void forEachFieldAsRaw(Hit.RawUtf8Consumer consumer)
      Description copied from class: Hit
      Receive a callback on the given object for each field in this hit, where the callback will provide raw utf-8 byte data for strings whose data is already available at this form. This is the most resource efficient way of traversing all the fields of a hit in renderers which produces utf-8.
      Overrides:
      forEachFieldAsRaw in class Hit
    • fields

      public Map<String,Object> fields()
      Description copied from class: Hit
      Returns the fields of this as a read-only map. This is more costly than fieldIterator()
      Overrides:
      fields in class Hit
    • fieldIterator

      public Iterator<Map.Entry<String,Object>> fieldIterator()
      Description copied from class: Hit
      Returns a modifiable iterator over the fields of this
      Overrides:
      fieldIterator in class Hit
    • fieldKeys

      public Set<String> fieldKeys()
      Returns the keys of the fields of this hit as a modifiable view. This follows the rules of key sets returned from maps: Key removals are reflected in the map, add and addAll is not supported.
      Overrides:
      fieldKeys in class Hit
    • clearFields

      public void clearFields()
      Removes all fields of this
      Overrides:
      clearFields in class Hit
    • removeField

      public Object removeField(String name)
      Removes a field from this
      Overrides:
      removeField in class Hit
      Returns:
      the removed value of the field, or null if none
    • hasField

      protected boolean hasField(String name)
      Returns whether this field is present in the field map in the parent hit
      Overrides:
      hasField in class Hit
    • hasFields

      protected boolean hasFields()
      Returns whether any fields are present in the field map in the parent hit
      Overrides:
      hasFields in class Hit
    • toString

      public String toString()
      Overrides:
      toString in class Hit
    • hashCode

      public int hashCode()
      Description copied from class: Hit
      Returns the hashCode of this hit: The hashcode of its id
      Overrides:
      hashCode in class Hit