Package com.yahoo.prelude.query
Class PhraseSegmentItem
- java.lang.Object
-
- All Implemented Interfaces:
BlockItem
,HasIndexItem
,IndexedItem
,TaggableItem
,java.lang.Cloneable
public class PhraseSegmentItem extends IndexedSegmentItem
A term which contains a fixed length phrase, a collection of word terms, resulting from a single segmentation operation.- Author:
- Steinar Knutsen
-
-
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
Constructors Constructor Description PhraseSegmentItem(AndSegmentItem andSegment)
Creates a phrase containing the same words and state (as pertinent) as the given SegmentAndItem.PhraseSegmentItem(java.lang.String rawWord, boolean isFromQuery, boolean stemmed)
PhraseSegmentItem(java.lang.String rawWord, java.lang.String current, boolean isFromQuery, boolean stemmed)
Creates a phrase segment from stringsPhraseSegmentItem(java.lang.String rawWord, java.lang.String current, boolean isFromQuery, boolean stemmed, Substring substring)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(Item item)
Adds subitem.protected void
appendBodyString(java.lang.StringBuilder buffer)
Override to append the item body in the canonical query language of this item.protected void
appendHeadingString(java.lang.StringBuilder buffer)
Segment phrase items uses a empty heading instead of "SPHRASE "void
disclose(com.yahoo.prelude.query.textualrepresentation.Discloser discloser)
int
encode(java.nio.ByteBuffer buffer)
int
encodeContent(java.nio.ByteBuffer buffer)
protected void
encodeThis(java.nio.ByteBuffer buffer)
Encodes just this item, not it's usual subitems, to the given buffer.boolean
equals(java.lang.Object object)
Returns whether this item is of the same class and contains the same state as the given itemjava.util.Optional<Item>
extractSingleChild()
Will return its single child if itself can safely be omitted.java.lang.String
getIndexedString()
Return the searchable term contents of this item.Item.ItemType
getItemType()
Return the enumerated type of this item.java.lang.String
getName()
Returns the name of this itemWordItem
getWordItem(int index)
Returns a subitem as a word itemboolean
isExplicit()
void
setExplicit(boolean explicit)
void
setIndexName(java.lang.String index)
Sets the name of the index to searchvoid
setWeight(int weight)
Sets the relative importance of this termprotected boolean
shouldParenthize()
Returns false, no parenthezes for phrases-
Methods inherited from class com.yahoo.prelude.query.IndexedSegmentItem
appendIndexString, getIndexName, hashCode
-
Methods inherited from class com.yahoo.prelude.query.TaggableSegmentItem
getConnectedItem, getConnectivity, getSignificance, getUniqueID, hasExplicitSignificance, hasUniqueID, setConnectivity, setExplicitSignificance, setSignificance, setUniqueID
-
Methods inherited from class com.yahoo.prelude.query.SegmentItem
addItem, clone, getNormalized, getNumWords, getOrigin, getRawWord, getSegmentingRule, isFromQuery, isFromUser, isLocked, isStemmed, isWords, lock, removeItem, removeItem, setFromUser, setSegmentingRule, stringValue
-
Methods inherited from class com.yahoo.prelude.query.CompositeItem
adding, encodingArity, ensureNotInSubtree, getItem, getItemCount, getItemIndex, getItemIterator, getTermCount, items, setItem
-
Methods inherited from class com.yahoo.prelude.query.Item
addAnnotation, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, toString, usePositionData
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.yahoo.prelude.query.HasIndexItem
getNumWords
-
-
-
-
Constructor Detail
-
PhraseSegmentItem
public PhraseSegmentItem(AndSegmentItem andSegment)
Creates a phrase containing the same words and state (as pertinent) as the given SegmentAndItem.
-
PhraseSegmentItem
public PhraseSegmentItem(java.lang.String rawWord, boolean isFromQuery, boolean stemmed)
-
PhraseSegmentItem
public PhraseSegmentItem(java.lang.String rawWord, java.lang.String current, boolean isFromQuery, boolean stemmed)
Creates a phrase segment from strings- Parameters:
rawWord
- the raw text as received in the requestcurrent
- the normalized form of the raw text, or the raw text repeated if no normalized form is knownisFromQuery
- whether this originates in the requeststemmed
- whether this is stemmed
-
PhraseSegmentItem
public PhraseSegmentItem(java.lang.String rawWord, java.lang.String current, boolean isFromQuery, boolean stemmed, Substring substring)
-
-
Method Detail
-
getItemType
public Item.ItemType getItemType()
Description copied from class:Item
Return the enumerated type of this item.- Specified by:
getItemType
in classItem
-
getName
public java.lang.String getName()
Description copied from class:Item
Returns the name of this item
-
setIndexName
public void setIndexName(java.lang.String index)
Description copied from class:IndexedSegmentItem
Sets the name of the index to search- Specified by:
setIndexName
in interfaceIndexedItem
- Overrides:
setIndexName
in classIndexedSegmentItem
-
setWeight
public void setWeight(int weight)
Description copied from class:Item
Sets the relative importance of this term
-
addItem
public void addItem(Item item)
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 classSegmentItem
- Throws:
java.lang.IllegalArgumentException
- if the given item is not a WordItem or PhraseItem
-
extractSingleChild
public java.util.Optional<Item> extractSingleChild()
Description copied from class:CompositeItem
Will return its single child if itself can safely be omitted.- Overrides:
extractSingleChild
in classCompositeItem
- Returns:
- a valid Item or empty Optional if it can not be done
-
getWordItem
public WordItem getWordItem(int index)
Returns a subitem as a word item- Parameters:
index
- the (0-base) index of the item to return- Throws:
java.lang.IndexOutOfBoundsException
- if there is no subitem at index
-
encodeThis
protected void encodeThis(java.nio.ByteBuffer buffer)
Description copied from class:CompositeItem
Encodes just this item, not it's usual subitems, to the given buffer.- Overrides:
encodeThis
in classIndexedSegmentItem
-
encode
public int encode(java.nio.ByteBuffer buffer)
- Overrides:
encode
in classCompositeItem
-
encodeContent
public int encodeContent(java.nio.ByteBuffer buffer)
-
shouldParenthize
protected boolean shouldParenthize()
Returns false, no parenthezes for phrases- Overrides:
shouldParenthize
in classCompositeItem
-
appendHeadingString
protected void appendHeadingString(java.lang.StringBuilder buffer)
Segment phrase items uses a empty heading instead of "SPHRASE "- Overrides:
appendHeadingString
in classItem
-
appendBodyString
protected void appendBodyString(java.lang.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.- Overrides:
appendBodyString
in classCompositeItem
-
equals
public boolean equals(java.lang.Object object)
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 classIndexedSegmentItem
-
getIndexedString
public java.lang.String getIndexedString()
Description copied from interface:IndexedItem
Return the searchable term contents of this item.- Specified by:
getIndexedString
in interfaceIndexedItem
- Specified by:
getIndexedString
in classIndexedSegmentItem
- Returns:
- a string representation of what is presumably stored in an index which will match this item
-
isExplicit
public boolean isExplicit()
-
setExplicit
public void setExplicit(boolean explicit)
-
disclose
public void disclose(com.yahoo.prelude.query.textualrepresentation.Discloser discloser)
- Overrides:
disclose
in classIndexedSegmentItem
-
-