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,Cloneable
- Direct Known Subclasses:
DotProductItem,WandItem
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, documentFrequency, explicitSignificance, significance, uniqueID -
Constructor Summary
ConstructorsConstructorDescriptionWeightedSetItem(String indexName) Creates an empty weighted set; note you must provide an index name up frontWeightedSetItem(String indexName, Map<Object, Integer> map) -
Method Summary
Modifier and TypeMethodDescriptionaddToken(long value, int weight) Adds a token with weight 1.Adds a weighted token.protected voidappendBodyString(StringBuilder buffer) Override to append the item body in the canonical query language of this item.clone()Returns a deep copy of this itemvoidintencode(ByteBuffer buffer) protected voidencodeThis(ByteBuffer buffer) booleanReturns whether this item is of the same class and contains the same state as the given item.Return the enumerated type of this item.getName()Returns the name of this itemintintgetTokenWeight(Object token) inthashCode()protected booleanDetects if this weighted set contains only long values (no strings).removeToken(String token) voidsetIndexName(String index) Sets the index name of this itemMethods 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, 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
-
WeightedSetItem
Creates an empty weighted set; note you must provide an index name up front -
WeightedSetItem
-
-
Method Details
-
addToken
-
addToken
Adds a weighted token. If this token is already in the set, the maximum weight is kept. The weight must be 1 or more; negative values (and zero) are not allowed.- Returns:
- the weight of the added token (might be the old value, if kept)
-
addToken
Adds a token with weight 1. -
getTokenWeight
-
removeToken
-
getNumTokens
public int getNumTokens() -
getTokens
-
setIndexName
Description copied from class:ItemSets the index name of this item- Specified by:
setIndexNamein classItem
-
getIndexName
-
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 -
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
-
encode
-
encodeThis
- Overrides:
encodeThisin classItem
-
getTermCount
public int getTermCount()- Specified by:
getTermCountin classItem
-
clone
Description copied from class:ItemReturns a deep copy of this item -
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() -
hasOnlyLongs
protected boolean hasOnlyLongs()Detects if this weighted set contains only long values (no strings). Used to determine which protobuf message type to use for serialization.- Returns:
- true if all tokens are Long values, false if any token is a String
-