org.terrier.querying
Class Request

java.lang.Object
  extended by org.terrier.querying.Request
All Implemented Interfaces:
Serializable, SearchRequest

public class Request
extends Object
implements SearchRequest

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:

A Request is an implementation of the SearchRequest interface. Additionally, the Request holds all the controls set for this query.

Author:
Craig Macdonald, Dyaa Albakour
See Also:
Serialized Form

Field Summary
protected  Map<String,Object> contextObjects
          Context object Map that can hold object values.
protected  Map<String,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 RMI
protected  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 filtering
protected  String originalQuery
          The query text, before applying any pre-processsing
protected  Query q
          This contains the parsed syntax tree of the query, as generated by the Antlr parser
protected  String QueryID
          QueryID - used by TREC querying and output format for supporting relevance assessments
protected  ResultSet resultSet
          This is the resultset of the query.
 
Constructor Summary
Request()
           
 
Method Summary
 void addMatchingModel(String MatchingModelName, String WeightingModelName)
          Set the matching model and weighting model that the Manager should use for this query
 Object getContextObject(String key)
          Returns the value of a context object.
 String getControl(String Name)
          Returns the value of the control.
 Map<String,String> getControlHashtable()
          Get the entire hashtable used for storing controls for this query
 Index getIndex()
          Returns the index to be used for this query
 String getMatchingModel()
          returns the name of the matching model that should be used for retrieval
 MatchingQueryTerms getMatchingQueryTerms()
          Return the MatchingQueryTerms object to use for matching
 int getNumberOfDocumentsAfterFiltering()
          returns the number of documents in the result set after applying post filters.
 String getOriginalQuery()
          gets the string of the original query, before applying any pre-processing.
 Query getQuery()
          Get the Query syntax tree
 String getQueryID()
          Returns the query id as set by setQueryID(String).
 ResultSet getResultSet()
          Returns the resultset generated by the query.
 long getStartedProcessingTime()
          returns the time when the processing of the request started.
 String getWeightingModel()
          returns the name of the weighting model that should be used for retrieval
 boolean isEmpty()
          Set if the query input had no terms.
 void setContextObject(String key, Object value)
          Set a value of a context object.
 void setControl(String Name, String Value)
          Set a control named to have value Value.
 void setControls(Map<String,String> controls)
          Use this hashtable to store controls and their values in
 void 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 query
 void 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(String _q)
          sets the string of the original query, before applying any pre-processing
 void setQuery(Query _q)
          Set the query to be a parsed Query syntax tree, as generated by the Terrier query parser
 void setQueryID(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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 String QueryID
QueryID - used by TREC querying and output format for supporting relevance assessments


Control

protected Map<String,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 Map<String,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 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

Constructor Detail

Request

public Request()
Method Detail

addMatchingModel

public void addMatchingModel(String MatchingModelName,
                             String WeightingModelName)
Set the matching model and weighting model that the Manager should use for this query

Specified by:
addMatchingModel in interface SearchRequest
Parameters:
MatchingModelName - the String class name that should be used
WeightingModelName - 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

Specified by:
setQuery in interface SearchRequest
Parameters:
_q - The Query object syntax tree

setQueryID

public void setQueryID(String qid)
Set a unique identifier for this query request.

Specified by:
setQueryID in interface SearchRequest
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(String Name,
                       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 interface SearchRequest
Parameters:
Name - the name of the control to set the value of.
Value - the value that the control should take.

getControl

public String getControl(String Name)
Returns the value of the control. Null or empty string if not set.

Specified by:
getControl in interface SearchRequest
Returns:
the value.

getResultSet

public ResultSet getResultSet()
Returns the resultset generated by the query. Before retrieving this you probably need to have run Manager.runMatching, and (optionally, at your own risk) Manager.runPostProcesses() and Manager.runPostFiltering().

Specified by:
getResultSet in interface SearchRequest
Returns:
the resultset - ie the set of document Ids and their scores.

getQueryID

public String getQueryID()
Returns the query id as set by setQueryID(String).

Specified by:
getQueryID in interface SearchRequest
Returns:
the query Id as a string.

getQuery

public Query getQuery()
Get the Query syntax tree

Specified by:
getQuery in interface SearchRequest
Returns:
The query object as set with setQuery.

isEmpty

public boolean isEmpty()
Set if the query input had no terms.

Specified by:
isEmpty in interface SearchRequest
Returns:
true if the query has no terms.

getWeightingModel

public String getWeightingModel()
returns the name of the weighting model that should be used for retrieval


getMatchingModel

public String getMatchingModel()
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.


getControlHashtable

public Map<String,String> getControlHashtable()
Get the entire hashtable used for storing controls for this query


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(Map<String,String> controls)
Use this hashtable to store controls and their values in


setOriginalQuery

public void setOriginalQuery(String _q)
sets the string of the original query, before applying any pre-processing

Specified by:
setOriginalQuery in interface SearchRequest

getOriginalQuery

public String getOriginalQuery()
gets the string of the original query, before applying any pre-processing.

Specified by:
getOriginalQuery in interface SearchRequest

setNumberOfDocumentsAfterFiltering

public void setNumberOfDocumentsAfterFiltering(int n)
sets the number of documents in the result set, after applying post filters.

Specified by:
setNumberOfDocumentsAfterFiltering in interface SearchRequest

getNumberOfDocumentsAfterFiltering

public int getNumberOfDocumentsAfterFiltering()
returns the number of documents in the result set after applying post filters.

Specified by:
getNumberOfDocumentsAfterFiltering in interface SearchRequest
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 interface SearchRequest
Returns:
time long

setStartedProcessingTime

public void setStartedProcessingTime(long _startedProcessingTime)
sets the time when the processing of the request started

Specified by:
setStartedProcessingTime in interface SearchRequest
Parameters:
_startedProcessingTime - the time obtained from a call to System.currentTimeMillis()

setContextObject

public void setContextObject(String key,
                             Object value)
Set a value of a context object.

Specified by:
setContextObject in interface SearchRequest
Parameters:
key - the key of the context object
value - the value of the context object

getContextObject

public Object getContextObject(String key)
Returns the value of a context object.

Specified by:
getContextObject in interface SearchRequest
Parameters:
key - the key of the context object to get
Returns:
the value of the context object for the given key


Terrier 3.6. Copyright © 2004-2011 University of Glasgow