Package org.terrier.querying.parser
Class Query
- java.lang.Object
-
- org.terrier.querying.parser.Query
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
- Direct Known Subclasses:
FieldQuery,MultiTermQuery,RequirementQuery,SingleTermQuery
public abstract class Query extends java.lang.Object implements java.io.Serializable, java.lang.CloneableAn abstract class that models a query, that consists of subqueries and query terms. The subqueries can be phrase queries, field queries, required queries, and combinations of those queries.- Author:
- Vassilis Plachouras & Craig Macdonald
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceQuery.ForEachQueryNodeForEachQueryNode interfacestatic classQuery.QTPBuilderstatic classQuery.QueryTermsParameter
-
Field Summary
Fields Modifier and Type Field Description protected QuerychildAn encapsulated query.protected static SingleTermQuery[]tmpSTQAn attribute used constructing arrays of the right type.
-
Constructor Summary
Constructors Constructor Description Query()default constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidapply(Query.ForEachQueryNode processor)Apply the specified processor to this node.booleanapplyTermPipeline(TermPipelineAccessor tpa)Applies a term pipeline in the query's terms, through the given term pipeline accessor.java.lang.Objectclone()Deep copy this Query objectprotected voidgetTerms(java.util.List<Query> alist)Returns the terms of the query.abstract voidgetTermsOf(java.lang.Class<? extends Query> c, java.util.List<Query> alist, boolean req)Returns all the query terms, in subqueries that are instances of a given classvoidobtainAllOf(java.lang.Class<? extends Query> c, java.util.List<Query> a)Returns all the queries of the specified classbooleanobtainControls(java.util.Set<java.lang.String> allowed, java.util.Map<java.lang.String,java.lang.String> controls)Returns the specified control or false if that control does not existabstract voidobtainQueryTerms(MatchingQueryTerms terms, java.lang.String field, java.lang.Boolean required, java.lang.Double weight)abstract voidobtainQueryTerms(Query.QueryTermsParameter parameters)abstract java.lang.StringparseTree()Returns the parse tree for the query as a stringvoidsetChild(Query q)Sets the subquery object of this query.abstract java.lang.StringtoString()Force anything concrete to provide toString method
-
-
-
Field Detail
-
child
protected Query child
An encapsulated query.
-
tmpSTQ
protected static final SingleTermQuery[] tmpSTQ
An attribute used constructing arrays of the right type.
-
-
Method Detail
-
clone
public java.lang.Object clone()
Deep copy this Query object- Overrides:
clonein classjava.lang.Object
-
toString
public abstract java.lang.String toString()
Force anything concrete to provide toString method- Overrides:
toStringin classjava.lang.Object
-
parseTree
public abstract java.lang.String parseTree()
Returns the parse tree for the query as a string
-
getTermsOf
public abstract void getTermsOf(java.lang.Class<? extends Query> c, java.util.List<Query> alist, boolean req)
Returns all the query terms, in subqueries that are instances of a given class- Parameters:
c- Class a class of queries.alist- ArrayList the list of query terms.req- boolean indicates whether it the subqueries are required or not.
-
setChild
public void setChild(Query q)
Sets the subquery object of this query.- Parameters:
q- Query the subquery object.
-
applyTermPipeline
public boolean applyTermPipeline(TermPipelineAccessor tpa)
Applies a term pipeline in the query's terms, through the given term pipeline accessor.- Parameters:
tpa- TermPipelineAccessor the object that provides access to the term pipeline.- Returns:
- boolean true if the query is not empty, otherwise returns false.
-
obtainControls
public boolean obtainControls(java.util.Set<java.lang.String> allowed, java.util.Map<java.lang.String,java.lang.String> controls)Returns the specified control or false if that control does not exist
-
obtainQueryTerms
public abstract void obtainQueryTerms(MatchingQueryTerms terms, java.lang.String field, java.lang.Boolean required, java.lang.Double weight)
-
obtainQueryTerms
public abstract void obtainQueryTerms(Query.QueryTermsParameter parameters)
-
getTerms
protected void getTerms(java.util.List<Query> alist)
Returns the terms of the query.- Parameters:
alist- A structure that contains the query terms.
-
apply
public void apply(Query.ForEachQueryNode processor)
Apply the specified processor to this node. If the processor allows, move to any children nodes.- Parameters:
processor-
-
-