Class NearestNeighborItem

All Implemented Interfaces:
TaggableItem, Cloneable

public class NearestNeighborItem extends SimpleTaggableItem
Represent a query item matching the K nearest neighbors in a multidimensional vector space. The query point vector is referenced by the name of a tensor passed as a query rank feature; specifying "myvector" as the name means the query must set "ranking.features.query(myvector)". This rank feature must be configured with the correct tensor type in the active query profile. The field name (AKA the index name) given must be an attribute, with the exact same tensor type.
Author:
arnej
  • Constructor Details

    • NearestNeighborItem

      public NearestNeighborItem(String fieldName, String queryTensorName)
  • Method Details

    • getTargetNumHits

      public int getTargetNumHits()
      Returns the K number of hits to produce
    • getIndexName

      public String getIndexName()
      Returns the name of the index (field) to be searched
    • getDistanceThreshold

      public double getDistanceThreshold()
      Returns the distance threshold for nearest-neighbor hits
    • getHnswExploreAdditionalHits

      public int getHnswExploreAdditionalHits()
      Returns the number of extra hits to explore in HNSW algorithm
    • getAllowApproximate

      public boolean getAllowApproximate()
      Returns whether approximation is allowed
    • getQueryTensorName

      public String getQueryTensorName()
      Returns the name of the query tensor
    • getHnswApproximateThreshold

      public Double getHnswApproximateThreshold()
      Returns the approximate threshold for HNSW
    • getHnswExplorationSlack

      public Double getHnswExplorationSlack()
      Returns the exploration slack for HNSW
    • getHnswFilterFirstExploration

      public Double getHnswFilterFirstExploration()
      Returns the filter-first exploration parameter for HNSW
    • getHnswFilterFirstThreshold

      public Double getHnswFilterFirstThreshold()
      Returns the filter-first threshold for HNSW
    • getHnswPostFilterThreshold

      public Double getHnswPostFilterThreshold()
      Returns the post-filter threshold for HNSW
    • getHnswTargetHitsMaxAdjustmentFactor

      public Double getHnswTargetHitsMaxAdjustmentFactor()
      Returns the target hits max adjustment factor for HNSW
    • setTargetNumHits

      public void setTargetNumHits(int target)
      Set the K number of hits to produce
    • setDistanceThreshold

      public void setDistanceThreshold(double threshold)
      Set the distance threshold for nearest-neighbor hits
    • setHnswExploreAdditionalHits

      public void setHnswExploreAdditionalHits(int num)
      Set the number of extra hits to explore in HNSW algorithm
    • setAllowApproximate

      public void setAllowApproximate(boolean value)
      Set whether approximation is allowed
    • setHnswApproximateThreshold

      public void setHnswApproximateThreshold(Double value)
      Set the approximate threshold for HNSW
    • setHnswExplorationSlack

      public void setHnswExplorationSlack(Double value)
      Set the exploration slack for HNSW
    • setHnswFilterFirstExploration

      public void setHnswFilterFirstExploration(Double value)
      Set the filter-first exploration parameter for HNSW
    • setHnswFilterFirstThreshold

      public void setHnswFilterFirstThreshold(Double value)
      Set the filter-first threshold for HNSW
    • setHnswPostFilterThreshold

      public void setHnswPostFilterThreshold(Double value)
      Set the post-filter threshold for HNSW
    • setHnswTargetHitsMaxAdjustmentFactor

      public void setHnswTargetHitsMaxAdjustmentFactor(Double value)
      Set the target hits max adjustment factor for HNSW
    • setIndexName

      public void setIndexName(String index)
      Description copied from class: Item
      Sets the index name of this item
      Specified by:
      setIndexName in class Item
    • getItemType

      public Item.ItemType getItemType()
      Description copied from class: Item
      Return the enumerated type of this item.
      Specified by:
      getItemType in class Item
    • getName

      public String getName()
      Description copied from class: Item
      Returns the name of this item
      Specified by:
      getName in class Item
    • getTermCount

      public int getTermCount()
      Specified by:
      getTermCount in class Item
    • encode

      public int encode(ByteBuffer buffer)
      Specified by:
      encode in class Item
    • appendBodyString

      protected void appendBodyString(StringBuilder buffer)
      Description copied from class: Item
      Override to append the item body in the canonical query language of this item. An item is usually represented by the string
       ([itemName] [body])
       
      The body must be appended by this method.
      Specified by:
      appendBodyString in class Item
    • disclose

      public void disclose(Discloser discloser)
      Overrides:
      disclose in class Item
    • equals

      public boolean equals(Object o)
      Description copied from class: Item
      Returns whether this item is of the same class and contains the same state as the given item.
      Overrides:
      equals in class Item
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Item