Package com.yahoo.search.query
Class QueryTree
- java.lang.Object
-
- com.yahoo.prelude.query.Item
-
- com.yahoo.prelude.query.CompositeItem
-
- com.yahoo.search.query.QueryTree
-
- All Implemented Interfaces:
java.lang.Cloneable
public class QueryTree extends CompositeItem
The root node of a query tree. This is always present above the actual semantic root to ease query manipulation, especially replacing the actual semantic root, but does not have any search semantics on its own.To ease recursive manipulation of the query tree, this is a composite having one child, which is the actual root.
- Setting the root item (at position 0, either directly or though the iterator of this, works as expected. Setting at any other position is disallowed.
- Removing the root is allowed and causes this to be a null query.
- Adding an item is only allowed if this is currently a null query (having no root)
This is also the home of accessor methods which eases querying into and manipulation of the query tree.
- Author:
- Arne Bergene Fossaa
-
-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addItem(int index, Item item)
Inserts the item at a position and increases the index of existing items starting on this position by onevoid
addItem(Item item)
Item
and(Item item)
Modifies this query to become the current query AND the given item.protected void
appendHeadingString(java.lang.StringBuilder sb)
Appends the heading of this string.QueryTree
clone()
Returns a deep copy of thisint
encode(java.nio.ByteBuffer buffer)
boolean
equals(java.lang.Object o)
Returns whether this item is of the same class and contains the same state as the given itemItem.ItemType
getItemType()
Return the enumerated type of this item.java.lang.String
getName()
Returns the name of this itemstatic java.util.List<IndexedItem>
getPositiveTerms(Item item)
Returns a flattened list of all positive query terms under the given itemItem
getRoot()
Returns the query root.boolean
isEmpty()
Returns true if this represents the null queryvoid
setIndexName(java.lang.String index)
Sets the index name of all subitems of thisvoid
setRoot(Item root)
-
Methods inherited from class com.yahoo.prelude.query.CompositeItem
adding, appendBodyString, disclose, encodeThis, encodingArity, ensureNotInSubtree, extractSingleChild, getItem, getItemCount, getItemIndex, getItemIterator, getTermCount, hashCode, isLocked, items, lock, removeItem, removeItem, setItem, shouldParenthize
-
Methods inherited from class com.yahoo.prelude.query.Item
addAnnotation, getAnnotation, getBytes, getCode, getCreator, getLabel, getLanguage, getParent, getWeight, hasAnnotation, hasConnectivityBackLink, hasUniqueID, isFilter, isFromSpecialToken, isProtected, isRanked, isRoot, putBytes, putString, setCreator, setFilter, setFromSpecialToken, setHasUniqueID, setLabel, setLanguage, setParent, setPositionData, setProtected, setRanked, setWeight, toString, usePositionData
-
-
-
-
Constructor Detail
-
QueryTree
public QueryTree(Item root)
-
-
Method Detail
-
setIndexName
public void setIndexName(java.lang.String index)
Description copied from class:CompositeItem
Sets the index name of all subitems of this- Overrides:
setIndexName
in classCompositeItem
-
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
-
encode
public int encode(java.nio.ByteBuffer buffer)
- Overrides:
encode
in classCompositeItem
-
appendHeadingString
protected void appendHeadingString(java.lang.StringBuilder sb)
Description copied from class:Item
Appends the heading of this string. As default getName() followed by a space.- Overrides:
appendHeadingString
in classItem
-
getRoot
public Item getRoot()
Returns the query root. This is null if this is a null query.
-
setRoot
public final void setRoot(Item root)
-
equals
public boolean equals(java.lang.Object o)
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 classCompositeItem
-
clone
public QueryTree clone()
Returns a deep copy of this- Overrides:
clone
in classCompositeItem
-
addItem
public void addItem(Item item)
- Overrides:
addItem
in classCompositeItem
-
addItem
public void addItem(int index, Item item)
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
-
isEmpty
public boolean isEmpty()
Returns true if this represents the null query
-
and
public Item and(Item item)
Modifies this query to become the current query AND the given item.- Returns:
- the resulting root item in this
-
getPositiveTerms
public static java.util.List<IndexedItem> getPositiveTerms(Item item)
Returns a flattened list of all positive query terms under the given item
-
-