Package com.yahoo.prelude.query
Class NotItem
java.lang.Object
com.yahoo.prelude.query.Item
com.yahoo.prelude.query.CompositeItem
com.yahoo.prelude.query.NotItem
- All Implemented Interfaces:
Cloneable
A composite item where the first item is positive and the following
items are negative items where matches should exclude the document should from the result.
The default positive item, if only negatives are added, is TrueItem: Meaning that all documents are matched
except those matching the negative terms added.
- Author:
- bratseth
-
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 TypeMethodDescriptionvoidAdds an item.voidaddNegativeItem(Item negative) Adds a negative item.voidaddPositiveItem(Item item) Convenience method for adding a positive item.protected voidappendBodyString(StringBuilder buffer) Overridden to skip the positive TrueItem and (otherwise) append "+" to the first item and "-" to the restprotected voidappendHeadingString(StringBuilder buffer) Not items uses a empty heading instead of "NOT "Return the enumerated type of this item.getName()Returns the name of this itemReturns the positive item (the first subitem), or TrueItem if no positive items has been added.intReturns the number of actual *positive* terms in thisReturns the negative items of this: All child items except the firstremoveItem(int index) Removes the item at the given indexbooleanremoveItem(Item item) Removes the given item.setPositiveItem(Item item) Sets the positive item (the first item)Methods inherited from class com.yahoo.prelude.query.CompositeItem
acceptsItemsOfType, adding, addItem, clone, disclose, encode, encodeThis, encodingArity, ensureNotInSubtree, equals, extractSingleChild, getItem, getItemCount, getItemIndex, getItemIterator, hashCode, isLocked, items, lock, setIndexName, setItem, shouldParenthesizeMethods inherited from class com.yahoo.prelude.query.Item
addAnnotation, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasPrefixMatchSemantics, hasUniqueID, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, toString, usePositionData
-
Constructor Details
-
NotItem
public NotItem()
-
-
Method Details
-
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 -
addItem
Adds an item. The first item is the positive, the rest are negative- Overrides:
addItemin classCompositeItem
-
addNegativeItem
Adds a negative item. Like addItem but skips the first position (position 0) if it is not already set. -
negativeItems
Returns the negative items of this: All child items except the first -
getPositiveItem
Returns the positive item (the first subitem), or TrueItem if no positive items has been added. -
setPositiveItem
Sets the positive item (the first item)- Returns:
- the old positive item, or TrueItem if there was none
-
addPositiveItem
Convenience method for adding a positive item. If a positive item is already present the positive item becomes an AndItem with the items added -
removeItem
Description copied from class:CompositeItemRemoves the given item. Does nothing if the item is not present.- Overrides:
removeItemin classCompositeItem- Parameters:
item- the item to remove- Returns:
- whether the item was removed
-
removeItem
Description copied from class:CompositeItemRemoves the item at the given index- Overrides:
removeItemin classCompositeItem- Parameters:
index- the index of the item to remove- Returns:
- the removed item
-
appendHeadingString
Not items uses a empty heading instead of "NOT "- Overrides:
appendHeadingStringin classItem
-
appendBodyString
Overridden to skip the positive TrueItem and (otherwise) append "+" to the first item and "-" to the rest- Overrides:
appendBodyStringin classCompositeItem
-
getTermCount
public int getTermCount()Returns the number of actual *positive* terms in this- Overrides:
getTermCountin classCompositeItem
-