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
,java.lang.Cloneable
@Beta public class NearestNeighborItem extends SimpleTaggableItem
Represent a query item matching the K nearest neighbors in a multi-dimensional 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, explicitSignificance, significance, uniqueID
-
-
Constructor Summary
Constructors Constructor Description NearestNeighborItem(java.lang.String fieldName, java.lang.String queryTensorName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
appendBodyString(java.lang.StringBuilder buffer)
Override to append the item body in the canonical query language of this item.void
disclose(Discloser discloser)
int
encode(java.nio.ByteBuffer buffer)
boolean
getAllowApproximate()
Returns whether approximation is allowedint
getHnswExploreAdditionalHits()
Returns the number of extra hits to explore in HNSW algorithmjava.lang.String
getIndexName()
Returns the field nameItem.ItemType
getItemType()
Return the enumerated type of this item.java.lang.String
getName()
Returns the name of this itemjava.lang.String
getQueryTensorName()
Returns the name of the query tensorint
getTargetNumHits()
Returns the K number of hits to produceint
getTermCount()
void
setAllowApproximate(boolean value)
Set whether approximation is allowedvoid
setHnswExploreAdditionalHits(int num)
Set the number of extra hits to explore in HNSW algorithmvoid
setIndexName(java.lang.String index)
Sets the index name of this itemvoid
setTargetNumHits(int target)
Set the K number of hits to produce-
Methods inherited from class com.yahoo.prelude.query.SimpleTaggableItem
getConnectedItem, getConnectivity, getSignificance, getUniqueID, hasExplicitSignificance, hasUniqueID, setConnectivity, setExplicitSignificance, setSignificance, setUniqueID
-
Methods inherited from class com.yahoo.prelude.query.Item
addAnnotation, appendHeadingString, clone, encodeThis, equals, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hashCode, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, shouldParenthize, toString, usePositionData
-
-
-
-
Method Detail
-
getTargetNumHits
public int getTargetNumHits()
Returns the K number of hits to produce
-
getIndexName
public java.lang.String getIndexName()
Returns the field name
-
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 java.lang.String getQueryTensorName()
Returns the name of the query tensor
-
setTargetNumHits
public void setTargetNumHits(int target)
Set the K number of hits to produce
-
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
public void setIndexName(java.lang.String index)
Description copied from class:Item
Sets the index name of this item- Specified by:
setIndexName
in classItem
-
getItemType
public Item.ItemType getItemType()
Description copied from class:Item
Return the enumerated type of this item.- Specified by:
getItemType
in classItem
-
getName
public java.lang.String getName()
Description copied from class:Item
Returns the name of this item
-
getTermCount
public int getTermCount()
- Specified by:
getTermCount
in classItem
-
appendBodyString
protected void appendBodyString(java.lang.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 appended by this method.- Specified by:
appendBodyString
in classItem
-
-