Package com.yahoo.prelude.query
Class PhraseItem
- All Implemented Interfaces:
HasIndexItem,IndexedItem,TaggableItem,Cloneable
- Direct Known Subclasses:
UriItem
A term which contains a phrase - a collection of word terms
- Author:
- bratseth, havardpe
-
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
ConstructorsConstructorDescriptionCreates an empty phrasePhraseItem(String indexName) Creates an empty phrase which will search the given indexPhraseItem(String[] words) Creates a phrase containing the given words -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsItemsOfType(Item.ItemType itemType) voidInserts the item at a position and increases the index of existing items starting on this position by onevoidAdds subitem.protected voidappendBodyString(StringBuilder buffer) Override to append the item body in the canonical query language of this item.protected voidappendHeadingString(StringBuilder buffer) Phrase items uses a empty heading instead of "PHRASE "voidintencode(ByteBuffer buffer) protected voidencodeThis(ByteBuffer buffer) Encodes just this item, not its regular subitems, to the given buffer.protected intbooleanReturns whether this item is of the same class and contains the same state as the given item.Returns the single child of this, if this can be omitted without changes to recall semantics.getBlockItem(int index) Returns a subitem as a block item,Return the searchable term contents of this item.Return the enumerated type of this item.getName()Returns the name of this itemintReturns how many phrase words does this item containgetWordItem(int index) Returns a subitem as a word iteminthashCode()booleanReturns whether this was explicitly written as a phrase using quotes by the user Default is falsevoidsetExplicit(boolean explicit) Sets whether this was explicitly written as a phrase using quotes by the uservoidsetIndexName(String index) Sets the name of the index to searchReplaces the item at the given index.voidsetWeight(int weight) Sets the relative importance of this termprotected booleanReturns false, no parenthezes for phrasesMethods inherited from class com.yahoo.prelude.query.CompositeIndexedItem
appendIndexString, getIndexNameMethods inherited from class com.yahoo.prelude.query.CompositeTaggableItem
getConnectedItem, getConnectivity, getDocumentFrequency, getSignificance, getUniqueID, hasExplicitSignificance, hasUniqueID, setConnectivity, setDocumentFrequency, setExplicitSignificance, setSignificance, setUniqueIDMethods inherited from class com.yahoo.prelude.query.CompositeItem
adding, clone, ensureNotInSubtree, getItem, getItemCount, getItemIndex, getItemIterator, getTermCount, isLocked, items, lock, removeItem, removeItemMethods inherited from class com.yahoo.prelude.query.Item
addAnnotation, 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, toString, usePositionData
-
Constructor Details
-
PhraseItem
public PhraseItem()Creates an empty phrase -
PhraseItem
Creates an empty phrase which will search the given index -
PhraseItem
Creates a phrase containing the given words
-
-
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 -
setIndexName
Description copied from class:CompositeIndexedItemSets the name of the index to search- Specified by:
setIndexNamein interfaceIndexedItem- Overrides:
setIndexNamein classCompositeIndexedItem
-
setExplicit
public void setExplicit(boolean explicit) Sets whether this was explicitly written as a phrase using quotes by the user -
isExplicit
public boolean isExplicit()Returns whether this was explicitly written as a phrase using quotes by the user Default is false -
addItem
Adds subitem. The word will have its index name set to the index name of this phrase. If the item is a word, it will simply be added, if the item is a phrase, each of the words of the phrase will be added.- Overrides:
addItemin classCompositeItem- Throws:
IllegalArgumentException- if the given item is not a WordItem or PhraseItem
-
addItem
Description copied from class:CompositeItemInserts the item at a position and increases the index of existing items starting on this position by one- Overrides:
addItemin classCompositeItem
-
setItem
Description copied from class:CompositeItemReplaces the item at the given index.- Overrides:
setItemin classCompositeItem- Parameters:
index- the (0-base) index of the item to replaceitem- the new item- Returns:
- the old item at this position. The parent of the old item is not cleared
-
acceptsItemsOfType
- Overrides:
acceptsItemsOfTypein classCompositeItem
-
extractSingleChild
Description copied from class:CompositeItemReturns the single child of this, if this can be omitted without changes to recall semantics.- Overrides:
extractSingleChildin classCompositeItem
-
setWeight
public void setWeight(int weight) Description copied from class:ItemSets the relative importance of this term -
getWordItem
Returns a subitem as a word item- Parameters:
index- the (0-base) index of the item to return- Throws:
IndexOutOfBoundsException- if there is no subitem at index
-
getBlockItem
Returns a subitem as a block item,- Parameters:
index- the (0-base) index of the item to return- Throws:
IndexOutOfBoundsException- if there is no subitem at index
-
encodeThis
Description copied from class:CompositeItemEncodes just this item, not its regular subitems, to the given buffer.- Overrides:
encodeThisin classCompositeIndexedItem
-
encode
- Overrides:
encodein classCompositeItem
-
shouldParenthesize
protected boolean shouldParenthesize()Returns false, no parenthezes for phrases- Overrides:
shouldParenthesizein classCompositeItem
-
appendHeadingString
Phrase items uses a empty heading instead of "PHRASE "- Overrides:
appendHeadingStringin classItem
-
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.- Overrides:
appendBodyStringin classCompositeItem
-
getIndexedString
Description copied from interface:IndexedItemReturn the searchable term contents of this item.- Specified by:
getIndexedStringin interfaceIndexedItem- Specified by:
getIndexedStringin classCompositeIndexedItem- Returns:
- a string representation of what is presumably stored in an index which will match this item
-
encodingArity
protected int encodingArity()- Overrides:
encodingArityin classCompositeItem
-
getNumWords
public int getNumWords()Description copied from interface:HasIndexItemReturns how many phrase words does this item contain -
disclose
- Overrides:
disclosein classCompositeIndexedItem
-
equals
Description copied from class:CompositeItemReturns whether this item is of the same class and contains the same state as the given item.- Overrides:
equalsin classCompositeIndexedItem
-
hashCode
public int hashCode()- Overrides:
hashCodein classCompositeIndexedItem
-