Package com.yahoo.prelude.query
Class Item
java.lang.Object
com.yahoo.prelude.query.Item
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
CompositeItem
,FalseItem
,InItem
,NullItem
,PureWeightedItem
,SimpleTaggableItem
,TrueItem
An item in the tree which defines which documents will match a query.
Item subclasses can be composed freely to create arbitrary complex matching trees.
Items are in general mutable and not thread safe.
They can be deeply cloned by calling clone().
Their identity is defined by their content
(i.e. the field value of two items decide if they are equal).
- Author:
- bratseth, havardpe
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Deprecated.static enum
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAnnotation
(String key, Object value) Annotate this itemprotected abstract void
appendBodyString
(StringBuilder buffer) Override to append the item body in the canonical query language of this item.protected void
appendHeadingString
(StringBuilder buffer) Appends the heading of this string.clone()
Returns a deep copy of this itemvoid
abstract int
encode
(ByteBuffer buffer) protected void
encodeThis
(ByteBuffer buffer) boolean
Returns whether this item is of the same class and contains the same state as the given item.getAnnotation
(String annotation) Returns an annotation on this item, or null if the annotation is not setprotected static byte[]
Utility method for turning a string into utf-8 bytesfinal int
getCode()
Returns the int code of this itemDeprecated.use isFilter(boolean)abstract Item.ItemType
Return the enumerated type of this item.getLabel()
Returns the label for this item.com.yahoo.language.Language
Returns the language of any natural language text below this item, or Language.UNKNOWN if not set.abstract String
getName()
Returns the name of this itemReturns the parent in the query tree, or null if this node has no parentabstract int
int
Returns the relative importance of this term.boolean
hasAnnotation
(String annotation) Returns whether this has an annotationboolean
DO NOT USEint
hashCode()
protected boolean
Indicates that a query item that does not normally match with prefix semantics should do so for this particular query item instance.protected boolean
boolean
isFilter()
Returns whether this is a filter termboolean
boolean
Returns whether this is to be protected from change/remove by query rewriters.boolean
isRanked()
Returns whether this item should affect ranking.boolean
isRoot()
Returns true if this is the root item - that is if the parent is the QueryTree (or null for legacy reasons)static void
putBytes
(byte[] bytes, ByteBuffer buffer) static void
putString
(String s, ByteBuffer buffer) void
setCreator
(Item.ItemCreator creator) Deprecated.use setFilter(boolean)void
setFilter
(boolean filter) Sets whether this is a filter term.void
setFromSpecialToken
(boolean fromSpecialToken) protected void
setHasUniqueID
(boolean hasUniqueID) abstract void
setIndexName
(String index) Sets the index name of this itemvoid
Label this item with a symbolic name which can later be used by the back-end to identify specific items for ranking purposes.void
setLanguage
(com.yahoo.language.Language language) Sets the language of any natural language text below this item.void
setParent
(CompositeItem parent) Sets the parent in the tree.void
setPositionData
(boolean usePositionData) Sets whether position data should be used when ranking this term item.void
setProtected
(boolean isProtected) Set whether this should be protected from change/remove by query rewritersvoid
setRanked
(boolean isRanked) Sets whether this term item should affect ranking.void
setWeight
(int w) Sets the relative importance of this termprotected boolean
Returns whether this item should be parenthesized when printed.toString()
Returns the canonical query language string of this item.boolean
Returns whether position data should be used when ranking this item
-
Field Details
-
DEFAULT_WEIGHT
public static final int DEFAULT_WEIGHT- See Also:
-
uniqueID
protected int uniqueIDUnique identifier to address the item for external annotation -
connectedItem
Items for explicit connectivity -
connectedBacklink
-
connectivity
protected double connectivity -
significance
protected double significanceExplicit term significance -
explicitSignificance
protected boolean explicitSignificance
-
-
Constructor Details
-
Item
public Item()
-
-
Method Details
-
setIndexName
Sets the index name of this item -
getCode
public final int getCode()Returns the int code of this item -
getItemType
Return the enumerated type of this item. -
getName
Returns the name of this item -
setFilter
public void setFilter(boolean filter) Sets whether this is a filter term. Filter terms are treated just like other terms except that they will not be highlighted in dynamic summaries. -
isFilter
public boolean isFilter()Returns whether this is a filter term -
hasPrefixMatchSemantics
protected boolean hasPrefixMatchSemantics()Indicates that a query item that does not normally match with prefix semantics should do so for this particular query item instance. False by default; should be overridden by subclasses that want to signal this behavior. -
getCreator
Deprecated.use isFilter(boolean)Returns the item creator value. -
setCreator
Deprecated.use setFilter(boolean)Sets the item creator value. -
setWeight
public void setWeight(int w) Sets the relative importance of this term -
getWeight
public int getWeight()Returns the relative importance of this term. Default is 100. -
addAnnotation
Annotate this item- Parameters:
key
- the annotation keyvalue
- the value, or null to set a valueless annotation
-
getAnnotation
Returns an annotation on this item, or null if the annotation is not set -
hasAnnotation
Returns whether this has an annotation -
setProtected
public void setProtected(boolean isProtected) Set whether this should be protected from change/remove by query rewriters -
isProtected
public boolean isProtected()Returns whether this is to be protected from change/remove by query rewriters. default is false -
setParent
Sets the parent in the tree. Do not use: Only to be called from CompositeItem/QueryTree -
getParent
Returns the parent in the query tree, or null if this node has no parent -
encode
-
encodeThis
-
getBytes
Utility method for turning a string into utf-8 bytes -
putString
-
putBytes
-
getTermCount
public abstract int getTermCount() -
toString
Returns the canonical query language string of this item. The canonical language represent an item by the string([itemName] [body])
where the body may recursively be other items. -
shouldParenthesize
protected boolean shouldParenthesize()Returns whether this item should be parenthesized when printed. Default is false - no parentheses -
appendHeadingString
Appends the heading of this string. As default getName() followed by a space. -
appendBodyString
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. -
clone
Returns a deep copy of this item -
equals
Returns whether this item is of the same class and contains the same state as the given item. -
hashCode
public int hashCode() -
hasUniqueID
protected boolean hasUniqueID() -
setHasUniqueID
protected void setHasUniqueID(boolean hasUniqueID) -
setLabel
Label this item with a symbolic name which can later be used by the back-end to identify specific items for ranking purposes.- Parameters:
label
- label for this item
-
getLabel
Returns the label for this item. This method will return null if no label has been set. -
setRanked
public void setRanked(boolean isRanked) Sets whether this term item should affect ranking. If set to false this term is not exposed to the ranking framework in the search backend. -
isRanked
public boolean isRanked()Returns whether this item should affect ranking. -
setPositionData
public void setPositionData(boolean usePositionData) Sets whether position data should be used when ranking this term item. If set to false the search backend uses fast bit vector data structures when matching on this term and only a few simple ranking features will be available when ranking this term. Note that setting this to false also saves a lot of CPU during matching as bit vector data structures are used. -
usePositionData
public boolean usePositionData()Returns whether position data should be used when ranking this item -
disclose
-
isFromSpecialToken
public boolean isFromSpecialToken() -
setFromSpecialToken
public void setFromSpecialToken(boolean fromSpecialToken) -
getLanguage
public com.yahoo.language.Language getLanguage()Returns the language of any natural language text below this item, or Language.UNKNOWN if not set. -
setLanguage
public void setLanguage(com.yahoo.language.Language language) Sets the language of any natural language text below this item. This cannot be set to null but can be set to Language.UNKNOWN -
hasConnectivityBackLink
public boolean hasConnectivityBackLink()DO NOT USE -
isRoot
public boolean isRoot()Returns true if this is the root item - that is if the parent is the QueryTree (or null for legacy reasons)
-