Class WeightedSetItem

All Implemented Interfaces:
TaggableItem, 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.
  • Constructor Details

    • WeightedSetItem

      public WeightedSetItem(String indexName)
      Creates an empty weighted set; note you must provide an index name up front
    • WeightedSetItem

      public WeightedSetItem(String indexName, Map<Object,Integer> map)
  • Method Details

    • addToken

      public Integer addToken(long value, int weight)
    • addToken

      public Integer addToken(String token, int weight)
      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

      public Integer addToken(String token)
      Adds a token with weight 1.
    • getTokenWeight

      public Integer getTokenWeight(Object token)
    • removeToken

      public Integer removeToken(String token)
    • getNumTokens

      public int getNumTokens()
    • getTokens

      public Iterator<Map.Entry<Object,Integer>> getTokens()
    • setIndexName

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

      public String getIndexName()
    • 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
    • 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 appended by this method.
      Specified by:
      appendBodyString in class Item
    • disclose

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

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

      protected void encodeThis(ByteBuffer buffer)
      Overrides:
      encodeThis in class Item
    • getTermCount

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

      public WeightedSetItem clone()
      Description copied from class: Item
      Returns a deep copy of this item
      Overrides:
      clone 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