Package org.terrier.querying
Class Request
- java.lang.Object
-
- org.terrier.querying.Request
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,SearchRequest
public class Request extends java.lang.Object implements SearchRequest, java.lang.Cloneable
Request contains the details of the search engine for one query, including the query itself, the resultset, the controls and the context objects. Controls set application specific parameters, which often load post processes, and postfilters, or set matching parameter. Context objects are arbitrary objects which you are passing to the post processes or postfilters. Controls often depict modules to be used for each stage of a query:- The matching and weighting modules to be used
- Process modules to apply transforms to the query or resultset
- postFilter modules to apply transforms to the resultset
- Author:
- Craig Macdonald, Dyaa Albakour
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>
contextObjects
Context object Map that can hold object values.protected java.util.Map<java.lang.String,java.lang.String>
Control
Controls are querying stage flags and variables.protected boolean
EmptyQuery
does the query have any terms.protected Index
index
index will not be passed across RMIprotected MatchingQueryTerms
matchingTerms
This is an aggregated form of the query terms, suitable for matching, which requires term frequencies for each term.protected int
numOfDocsAfterFiltering
The number of documents returned after performing post filteringprotected java.lang.String
originalQuery
The query text, before applying any pre-processsingprotected Query
q
This contains the parsed syntax tree of the query, as generated by the Antlr parserprotected java.lang.String
QueryID
QueryID - used by TREC querying and output format for supporting relevance assessmentsprotected ResultSet
resultSet
This is the resultset of the query.-
Fields inherited from interface org.terrier.querying.SearchRequest
CONTROL_MATCHING, CONTROL_WMODEL
-
-
Constructor Summary
Constructors Constructor Description Request()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addMatchingModel(java.lang.String MatchingModelName, java.lang.String WeightingModelName)
Set the matching model and weighting model that the Manager should use for this queryRequest
clone()
java.lang.Object
getContextObject(java.lang.String key)
Returns the value of a context object.java.lang.String
getControl(java.lang.String Name)
Returns the value of the control.java.lang.String
getControl(java.lang.String Name, java.lang.String Default)
Returns the value of the control.java.util.Map<java.lang.String,java.lang.String>
getControls()
Get the entire hashtable used for storing controls for this queryIndex
getIndex()
Returns the index to be used for this queryjava.lang.String
getMatchingModel()
Deprecated.MatchingQueryTerms
getMatchingQueryTerms()
Return the MatchingQueryTerms object to use for matchingint
getNumberOfDocumentsAfterFiltering()
returns the number of documents in the result set after applying post filters.java.lang.String
getOriginalQuery()
gets the string of the original query, before applying any pre-processing.Query
getQuery()
Get the Query syntax treejava.lang.String
getQueryID()
Returns the query id as set by setQueryID(String).ScoredDocList
getResults()
Get the resultsResultSet
getResultSet()
Returns the resultset generated by the query.long
getStartedProcessingTime()
returns the time when the processing of the request started.java.lang.String
getWeightingModel()
Deprecated.boolean
isEmpty()
Set if the query input had no terms.void
setContextObject(java.lang.String key, java.lang.Object value)
Set a value of a context object.void
setControl(java.lang.String Name, java.lang.String Value)
Set a control named to have value Value.void
setControls(java.util.Map<java.lang.String,java.lang.String> controls)
Use this hashtable to store controls and their values invoid
setEmpty(boolean in)
force this query to be seen as containing (no) terms.void
setIndex(Index _index)
Set the index to be used for this queryvoid
setMatchingQueryTerms(MatchingQueryTerms mqts)
Used by runPreProcessing after the query tree has been aggregated into a list of terms, each containing frequencies.void
setNumberOfDocumentsAfterFiltering(int n)
sets the number of documents in the result set, after applying post filters.void
setOriginalQuery(java.lang.String _q)
sets the string of the original query, before applying any pre-processingvoid
setQuery(Query _q)
Set the query to be a parsed Query syntax tree, as generated by the Terrier query parservoid
setQueryID(java.lang.String qid)
Set a unique identifier for this query request.void
setResultSet(ResultSet results)
Set the result set returned by this object to be this results.void
setStartedProcessingTime(long _startedProcessingTime)
sets the time when the processing of the request started-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.terrier.querying.SearchRequest
hasControl
-
-
-
-
Field Detail
-
EmptyQuery
protected boolean EmptyQuery
does the query have any terms. Used by Manager.runMatching() to short circuit the matching process - if this is set, then a resultset with 0 documents is created automatically.
-
QueryID
protected java.lang.String QueryID
QueryID - used by TREC querying and output format for supporting relevance assessments
-
Control
protected java.util.Map<java.lang.String,java.lang.String> Control
Controls are querying stage flags and variables. These are typically set by defaults in the configuration file, or by flags in the query itself (if querying.HTTPSearchEngine is used). They often depict which pre, matching, post and output modules will be used.
-
contextObjects
protected java.util.Map<java.lang.String,java.lang.Object> contextObjects
Context object Map that can hold object values.
-
q
protected Query q
This contains the parsed syntax tree of the query, as generated by the Antlr parser
-
originalQuery
protected java.lang.String originalQuery
The query text, before applying any pre-processsing
-
numOfDocsAfterFiltering
protected int numOfDocsAfterFiltering
The number of documents returned after performing post filtering
-
resultSet
protected ResultSet resultSet
This is the resultset of the query. It is provided by the matching/weighting stage, and may be operated on (eg decorated) by PostProcesses and PostFilters
-
matchingTerms
protected MatchingQueryTerms matchingTerms
This is an aggregated form of the query terms, suitable for matching, which requires term frequencies for each term.
-
index
protected transient Index index
index will not be passed across RMI
-
-
Method Detail
-
addMatchingModel
public void addMatchingModel(java.lang.String MatchingModelName, java.lang.String WeightingModelName)
Set the matching model and weighting model that the Manager should use for this query- Specified by:
addMatchingModel
in interfaceSearchRequest
- Parameters:
MatchingModelName
- the String class name that should be usedWeightingModelName
- the String class name that should be used
-
setQuery
public void setQuery(Query _q)
Set the query to be a parsed Query syntax tree, as generated by the Terrier query parser- Parameters:
_q
- The Query object syntax tree
-
setQueryID
public void setQueryID(java.lang.String qid)
Set a unique identifier for this query request.- Specified by:
setQueryID
in interfaceSearchRequest
- Parameters:
qid
- the unique string identifier
-
setIndex
public void setIndex(Index _index)
Set the index to be used for this query
-
getIndex
public Index getIndex()
Returns the index to be used for this query
-
setControl
public void setControl(java.lang.String Name, java.lang.String Value)
Set a control named to have value Value. This is essentially a hashtable wrappers. Controls are used to set properties of the retrieval process.- Specified by:
setControl
in interfaceSearchRequest
- Parameters:
Name
- the name of the control to set the value of.Value
- the value that the control should take.
-
getControl
public java.lang.String getControl(java.lang.String Name)
Returns the value of the control. Null or empty string if not set.- Specified by:
getControl
in interfaceSearchRequest
- Returns:
- the value.
-
getControl
public java.lang.String getControl(java.lang.String Name, java.lang.String Default)
Returns the value of the control. Null or empty string if not set.- Specified by:
getControl
in interfaceSearchRequest
- Returns:
- the value.
-
getResultSet
public ResultSet getResultSet()
Returns the resultset generated by the query. Before retrieving this you probably need to have run Manager.runSearchRequest().- Returns:
- ResultSet the raw matching resultset - ie the set of document Ids and their scores.
-
getResults
public ScoredDocList getResults()
Description copied from interface:SearchRequest
Get the results- Specified by:
getResults
in interfaceSearchRequest
-
getQueryID
public java.lang.String getQueryID()
Returns the query id as set by setQueryID(String).- Specified by:
getQueryID
in interfaceSearchRequest
- Returns:
- the query Id as a string.
-
getQuery
public Query getQuery()
Get the Query syntax tree- Returns:
- The query object as set with setQuery.
-
isEmpty
public boolean isEmpty()
Set if the query input had no terms.- Specified by:
isEmpty
in interfaceSearchRequest
- Returns:
- true if the query has no terms.
-
getWeightingModel
@Deprecated public java.lang.String getWeightingModel()
Deprecated.returns the name of the weighting model that should be used for retrieval
-
getMatchingModel
@Deprecated public java.lang.String getMatchingModel()
Deprecated.returns the name of the matching model that should be used for retrieval
-
setResultSet
public void setResultSet(ResultSet results)
Set the result set returned by this object to be this results.
-
getControls
public java.util.Map<java.lang.String,java.lang.String> getControls()
Get the entire hashtable used for storing controls for this query- Specified by:
getControls
in interfaceSearchRequest
-
setEmpty
public void setEmpty(boolean in)
force this query to be seen as containing (no) terms.- Parameters:
in
- set to true for query to be seen empty.
-
setMatchingQueryTerms
public void setMatchingQueryTerms(MatchingQueryTerms mqts)
Used by runPreProcessing after the query tree has been aggregated into a list of terms, each containing frequencies.- Parameters:
mqts
- The matchingqueryterms to use for matching.
-
getMatchingQueryTerms
public MatchingQueryTerms getMatchingQueryTerms()
Return the MatchingQueryTerms object to use for matching
-
setControls
public void setControls(java.util.Map<java.lang.String,java.lang.String> controls)
Use this hashtable to store controls and their values in
-
setOriginalQuery
public void setOriginalQuery(java.lang.String _q)
sets the string of the original query, before applying any pre-processing- Specified by:
setOriginalQuery
in interfaceSearchRequest
-
getOriginalQuery
public java.lang.String getOriginalQuery()
gets the string of the original query, before applying any pre-processing.- Specified by:
getOriginalQuery
in interfaceSearchRequest
-
setNumberOfDocumentsAfterFiltering
public void setNumberOfDocumentsAfterFiltering(int n)
sets the number of documents in the result set, after applying post filters.- Specified by:
setNumberOfDocumentsAfterFiltering
in interfaceSearchRequest
-
getNumberOfDocumentsAfterFiltering
public int getNumberOfDocumentsAfterFiltering()
returns the number of documents in the result set after applying post filters.- Specified by:
getNumberOfDocumentsAfterFiltering
in interfaceSearchRequest
- Returns:
- the number of documents returned for a search request. integer.
-
getStartedProcessingTime
public long getStartedProcessingTime()
returns the time when the processing of the request started.- Specified by:
getStartedProcessingTime
in interfaceSearchRequest
- Returns:
- time long
-
setStartedProcessingTime
public void setStartedProcessingTime(long _startedProcessingTime)
sets the time when the processing of the request started- Specified by:
setStartedProcessingTime
in interfaceSearchRequest
- Parameters:
_startedProcessingTime
- the time obtained from a call to System.currentTimeMillis()
-
setContextObject
public void setContextObject(java.lang.String key, java.lang.Object value)
Set a value of a context object.- Specified by:
setContextObject
in interfaceSearchRequest
- Parameters:
key
- the key of the context objectvalue
- the value of the context object
-
getContextObject
public java.lang.Object getContextObject(java.lang.String key)
Returns the value of a context object.- Specified by:
getContextObject
in interfaceSearchRequest
- Parameters:
key
- the key of the context object to get- Returns:
- the value of the context object for the given key
-
clone
public Request clone()
- Overrides:
clone
in classjava.lang.Object
-
-