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, explicitSignificance, significance, uniqueID
-
Constructor Summary
ConstructorDescriptionCreates 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 TypeMethodDescriptionboolean
acceptsItemsOfType
(Item.ItemType itemType) void
Inserts the item at a position and increases the index of existing items starting on this position by onevoid
Adds subitem.protected void
appendBodyString
(StringBuilder buffer) Override to append the item body in the canonical query language of this item.protected void
appendHeadingString
(StringBuilder buffer) Phrase items uses a empty heading instead of "PHRASE "void
int
encode
(ByteBuffer buffer) protected void
encodeThis
(ByteBuffer buffer) Encodes just this item, not its regular subitems, to the given buffer.protected int
boolean
Returns 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 itemint
Returns how many phrase words does this item containgetWordItem
(int index) Returns a subitem as a word itemint
hashCode()
boolean
Returns whether this was explicitly written as a phrase using quotes by the user Default is falsevoid
setExplicit
(boolean explicit) Sets whether this was explicitly written as a phrase using quotes by the uservoid
setIndexName
(String index) Sets the name of the index to searchReplaces the item at the given index.void
setWeight
(int weight) Sets the relative importance of this termprotected boolean
Returns false, no parenthezes for phrasesMethods inherited from class com.yahoo.prelude.query.CompositeIndexedItem
appendIndexString, getIndexName
Methods inherited from class com.yahoo.prelude.query.CompositeTaggableItem
getConnectedItem, getConnectivity, getSignificance, getUniqueID, hasExplicitSignificance, hasUniqueID, setConnectivity, setExplicitSignificance, setSignificance, setUniqueID
Methods inherited from class com.yahoo.prelude.query.CompositeItem
adding, clone, ensureNotInSubtree, getItem, getItemCount, getItemIndex, getItemIterator, getTermCount, isLocked, items, lock, removeItem, removeItem
Methods 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: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 -
setIndexName
Description copied from class:CompositeIndexedItem
Sets the name of the index to search- Specified by:
setIndexName
in interfaceIndexedItem
- Overrides:
setIndexName
in 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:
addItem
in classCompositeItem
- Throws:
IllegalArgumentException
- if the given item is not a WordItem or PhraseItem
-
acceptsItemsOfType
- Overrides:
acceptsItemsOfType
in classCompositeItem
-
addItem
Description copied from class:CompositeItem
Inserts the item at a position and increases the index of existing items starting on this position by one- Overrides:
addItem
in classCompositeItem
-
setItem
Description copied from class:CompositeItem
Replaces the item at the given index.- Overrides:
setItem
in 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
-
extractSingleChild
Description copied from class:CompositeItem
Returns the single child of this, if this can be omitted without changes to recall semantics.- Overrides:
extractSingleChild
in classCompositeItem
-
setWeight
public void setWeight(int weight) Description copied from class:Item
Sets 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:CompositeItem
Encodes just this item, not its regular subitems, to the given buffer.- Overrides:
encodeThis
in classCompositeIndexedItem
-
encode
- Overrides:
encode
in classCompositeItem
-
shouldParenthesize
protected boolean shouldParenthesize()Returns false, no parenthezes for phrases- Overrides:
shouldParenthesize
in classCompositeItem
-
appendHeadingString
Phrase items uses a empty heading instead of "PHRASE "- Overrides:
appendHeadingString
in classItem
-
appendBodyString
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.- Overrides:
appendBodyString
in classCompositeItem
-
getIndexedString
Description copied from interface:IndexedItem
Return the searchable term contents of this item.- Specified by:
getIndexedString
in interfaceIndexedItem
- Specified by:
getIndexedString
in classCompositeIndexedItem
- Returns:
- a string representation of what is presumably stored in an index which will match this item
-
encodingArity
protected int encodingArity()- Overrides:
encodingArity
in classCompositeItem
-
getNumWords
public int getNumWords()Description copied from interface:HasIndexItem
Returns how many phrase words does this item contain -
disclose
- Overrides:
disclose
in classCompositeIndexedItem
-
equals
Description copied from class:CompositeItem
Returns whether this item is of the same class and contains the same state as the given item.- Overrides:
equals
in classCompositeIndexedItem
-
hashCode
public int hashCode()- Overrides:
hashCode
in classCompositeIndexedItem
-