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, explicitSignificance, significance, uniqueID
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an item.void
addNegativeItem
(Item negative) Adds a negative item.void
addPositiveItem
(Item item) Convenience method for adding a positive item.protected void
appendBodyString
(StringBuilder buffer) Overridden to skip the positive TrueItem and (otherwise) append "+" to the first item and "-" to the restprotected void
appendHeadingString
(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.int
Returns 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 indexboolean
removeItem
(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, shouldParenthesize
Methods 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:Item
Return the enumerated type of this item.- Specified by:
getItemType
in classItem
-
getName
Description copied from class:Item
Returns the name of this item -
addItem
Adds an item. The first item is the positive, the rest are negative- Overrides:
addItem
in 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:CompositeItem
Removes the given item. Does nothing if the item is not present.- Overrides:
removeItem
in classCompositeItem
- Parameters:
item
- the item to remove- Returns:
- whether the item was removed
-
removeItem
Description copied from class:CompositeItem
Removes the item at the given index- Overrides:
removeItem
in 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:
appendHeadingString
in classItem
-
appendBodyString
Overridden to skip the positive TrueItem and (otherwise) append "+" to the first item and "-" to the rest- Overrides:
appendBodyString
in classCompositeItem
-
getTermCount
public int getTermCount()Returns the number of actual *positive* terms in this- Overrides:
getTermCount
in classCompositeItem
-