Package com.yahoo.prelude.query
Class NearestNeighborItem
java.lang.Object
com.yahoo.prelude.query.Item
com.yahoo.prelude.query.SimpleTaggableItem
com.yahoo.prelude.query.NearestNeighborItem
- All Implemented Interfaces:
TaggableItem,Cloneable
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
-
Nested Class Summary
Nested classes/interfaces inherited from class com.yahoo.prelude.query.Item
Item.ItemCreator, Item.ItemType -
Field Summary
Fields inherited from class com.yahoo.prelude.query.Item
connectedBacklink, connectedItem, connectivity, DEFAULT_WEIGHT, documentFrequency, explicitSignificance, significance, uniqueID -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendBodyString(StringBuilder buffer) Override to append the item body in the canonical query language of this item.voidintencode(ByteBuffer buffer) booleanReturns whether this item is of the same class and contains the same state as the given item.booleanReturns whether approximation is alloweddoubleReturns the distance threshold for nearest-neighbor hitsintReturns the number of extra hits to explore in HNSW algorithmReturns the name of the index (field) to be searchedReturn the enumerated type of this item.getName()Returns the name of this itemReturns the name of the query tensorintReturns the K number of hits to produceintinthashCode()voidsetAllowApproximate(boolean value) Set whether approximation is allowedvoidsetDistanceThreshold(double threshold) Set the distance threshold for nearest-neighbor hitsvoidsetHnswExploreAdditionalHits(int num) Set the number of extra hits to explore in HNSW algorithmvoidsetIndexName(String index) Sets the index name of this itemvoidsetTargetNumHits(int target) Set the K number of hits to produceMethods inherited from class com.yahoo.prelude.query.SimpleTaggableItem
getConnectedItem, getConnectivity, getDocumentFrequency, getSignificance, getUniqueID, hasExplicitSignificance, hasUniqueID, setConnectivity, setDocumentFrequency, setExplicitSignificance, setSignificance, setUniqueIDMethods inherited from class com.yahoo.prelude.query.Item
addAnnotation, appendHeadingString, clone, encodeThis, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasPrefixMatchSemantics, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, shouldParenthesize, toString, usePositionData
-
Constructor Details
-
NearestNeighborItem
-
-
Method Details
-
getTargetNumHits
public int getTargetNumHits()Returns the K number of hits to produce -
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
Returns the name of the query tensor -
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 -
setIndexName
Description copied from class:ItemSets the index name of this item- Specified by:
setIndexNamein classItem
-
getItemType
Description copied from class:ItemReturn the enumerated type of this item.- Specified by:
getItemTypein classItem
-
getName
Description copied from class:ItemReturns the name of this item -
getTermCount
public int getTermCount()- Specified by:
getTermCountin classItem
-
encode
-
appendBodyString
Description copied from class:ItemOverride 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:
appendBodyStringin classItem
-
disclose
-
equals
Description copied from class:ItemReturns whether this item is of the same class and contains the same state as the given item. -
hashCode
public int hashCode()
-