Package com.yahoo.prelude.query
Class WeightedSetItem
- java.lang.Object
-
- com.yahoo.prelude.query.Item
-
- com.yahoo.prelude.query.SimpleTaggableItem
-
- com.yahoo.prelude.query.WeightedSetItem
-
- All Implemented Interfaces:
TaggableItem
,java.lang.Cloneable
- Direct Known Subclasses:
DotProductItem
,WandItem
public class WeightedSetItem extends SimpleTaggableItem
A term which contains a weighted set. When using a weighted set to search a field, all tokens present in the searched field will be reverse matched against the weighted set. This means that using a weighted set to search a single-value attribute field will have similar semantics to using a normal term to search a weighted set field. The low-level matching information resulting from matching a document with a weighted set term will contain the weights of all the matched tokens in descending order. Each matched weight will be represented as a standard occurrence on position 0 in element 0.
-
-
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 WeightedSetItem(java.lang.String indexName)
Creates an empty weighted set; note you must provide an index name up frontWeightedSetItem(java.lang.String indexName, java.util.Map<java.lang.Object,java.lang.Integer> map)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Integer
addToken(long value, int weight)
java.lang.Integer
addToken(java.lang.String token)
Add token with weight 1.java.lang.Integer
addToken(java.lang.String token, int weight)
Add weighted token.protected void
appendBodyString(java.lang.StringBuilder buffer)
Override to append the item body in the canonical query language of this item.WeightedSetItem
clone()
Returns a deep copy of this itemvoid
disclose(Discloser discloser)
int
encode(java.nio.ByteBuffer buffer)
protected void
encodeThis(java.nio.ByteBuffer buffer)
java.lang.String
getIndexName()
Item.ItemType
getItemType()
Return the enumerated type of this item.java.lang.String
getName()
Returns the name of this itemint
getNumTokens()
int
getTermCount()
java.util.Iterator<java.util.Map.Entry<java.lang.Object,java.lang.Integer>>
getTokens()
java.lang.Integer
getTokenWeight(java.lang.String token)
java.lang.Integer
removeToken(java.lang.String token)
void
setIndexName(java.lang.String index)
Sets the index name of this item-
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, 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
-
addToken
public java.lang.Integer addToken(long value, int weight)
-
addToken
public java.lang.Integer addToken(java.lang.String token, int weight)
Add weighted token. If token is already in the set, the maximum weight is kept. NOTE: The weight must be 1 or more; negative values (and zero) are not allowed.- Returns:
- weight of added token (might be old value, if kept)
-
addToken
public java.lang.Integer addToken(java.lang.String token)
Add token with weight 1.
-
getTokenWeight
public java.lang.Integer getTokenWeight(java.lang.String token)
-
removeToken
public java.lang.Integer removeToken(java.lang.String token)
-
getNumTokens
public int getNumTokens()
-
getTokens
public java.util.Iterator<java.util.Map.Entry<java.lang.Object,java.lang.Integer>> getTokens()
-
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
-
getIndexName
public java.lang.String getIndexName()
-
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
-
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
-
encodeThis
protected void encodeThis(java.nio.ByteBuffer buffer)
- Overrides:
encodeThis
in classItem
-
getTermCount
public int getTermCount()
- Specified by:
getTermCount
in classItem
-
clone
public WeightedSetItem clone()
Description copied from class:Item
Returns a deep copy of this item
-
-